Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I recently made a post asking for a script that checks if the PC is damaged or not (http://www.edugeek.net/forums/scripts/152082-check-if-computer-fine-script.html)- thanks to @sted.

 

Here is the code which I've modified a bit:

 

Option Explicit

Dim objFSO, objFolder, objShell, objTextFile, objFile

Dim strDirectory, strFile, strText

Dim Message, result

Dim mydatestring, mytimestring, WshNetwork, wshShell, strComputerName

 

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

Set wshShell = WScript.CreateObject( "WScript.Shell" )

 

mydateString = Date()

mytimestring = Time()

strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

 

strDirectory = "\\ourservershare\E"

strFile = "DamageReport.csv"

'strText = "test"

 

result = Msgbox("Does this computer have any damage?", vbYesNo, "PC Damage Check")

 

If result = vbYes Then

MsgBox "Thank you for notifying ICT"

Result = "Damage Present"

Else

Msgbox "Thank you for checking"

Result = "No damage"

End If

 

' Create the File System Object

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

' Check that the strDirectory folder exists

If objFSO.FolderExists(strDirectory) Then

Set objFolder = objFSO.GetFolder(strDirectory)

Else

Set objFolder = objFSO.CreateFolder(strDirectory)

End If

 

If objFSO.FileExists(strDirectory & strFile) Then

Set objFolder = objFSO.GetFolder(strDirectory)

Else

Set objFile = objFSO.CreateTextFile(strDirectory & strFile)

End If

 

set objFile = nothing

set objFolder = nothing

' OpenTextFile Method needs a Const value

' ForAppending = 8 ForReading = 1, ForWriting = 2

Const ForAppending = 8

 

Set objTextFile = objFSO.OpenTextFile _

(strDirectory & strFile, ForAppending, True)

 

' Writes result every time you run this VBScript

objTextFile.WriteLine("PC," & strComputerName & "," & "USER," & WshNetwork.UserName &"," &"Date," & myDateString &"," & "Time," & myTimeString & "," & "Reason," & Result)

objTextFile.Close

 

It runs on a remote computer and does not give any error messages however, the file is not created. Any idea why? When I run the vbs. from my PC it crates the file no problem- it's just when I try to do it from a pupil machine.

Posted
if youre running it as a startup script you will need to give domain pcs/authenticated users modify rights to your server folder
Posted
if youre running it as a startup script you will need to give domain pcs/authenticated users modify rights to your server folder

 

Thanks. I've been trying now for some time and it doesn't want to work. The pupils have full access to the folder the file is being created yet it isn't there.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...