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

Hello,

 

Last week my work friend mentioned to me, that he saw a script somewhere that asks the user who just logged on, to select yes or no to this question: "Is this workstation damaged/faulty?". This is to make sure that users find and leave the workstation in good condition. It also needs to log who clicked yes or no. I know that this was somewhere on this forum but I cant find it.

 

Thanks

Posted
how do you want it to collect that info as you could probably run something up in vbs in an hour or so if its just dumping to a text fille bit longer if its emailing
Posted
how do you want it to collect that info as you could probably run something up in vbs in an hour or so if its just dumping to a text fille bit longer if its emailing

 

Do you know a way..?

Posted

i wasnt planning on writing it but if you just change the displayed text & save location in this it should do the job just depends what you need it to do (it was designed for something else but if all you want is a does this pc work yes/no/type should do the trick

 

Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
Dim Message, result
Dim Title, Text1, Text2, 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 = "C:\Users\Jonathan\Desktop"
strFile = "\netbook usage.csv"
'strText = ""

' Define dialog box variables.
Message = "Why are you using this PC/Laptop"           
Title = "PC Usage Survey"
Text1 = "User input canceled"
Text2 = "You entered:" & vbCrLf

' Ready to use the InputBox function ' InputBox(prompt, title, default, xpos, ypos) ' prompt:    The text shown in the dialog box
' title:     The title of the dialog box ' default:   Default value shown in the text box ' xpos/ypos: Upper left position of the dialog box 
' If a parameter is omitted, VBScript uses a default value.

result = InputBox(Message, Title, "", 100, 100)

' Evaluate the user input.
'If result = "" Then    ' Canceled by the user
'    WScript.Echo Text1
'Else 
'    WScript.Echo Text2 & result
'End If

'writeout bits
'
' 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)
  WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
  Wscript.Echo "Just created " & 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("Pcname," & strComputerName & "," & "Username," & WshNetwork.UserName &"," &"Date," & myDateString &"," & "Time," & myTimeString & "," & "Reason," & Result)
objTextFile.Close

  • Thanks 1

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...