Jacob Loperson
asked on
Adding a text output with VBScript
I would like to attach write username to this script so that every time someone has run the program and input their username, the said username is output to a text file on the same usb thumb drive the program is being run from so that we have inventory of everyone that has successfully ran the cleaner on their computer. Anyone know how I can implement this into the code?
Option Explicit
On Error Resume Next
Dim strInput
strInput = UserInput( "Please Enter Your Name" )
WScript.Echo "Welcome: " & strInput
WScript.Echo "Are you ready to have a clean PC?"
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("taskkill /fi ""imagename eq iexplore.exe""")
Set oExec = WshShell.Exec("taskkill /fi ""imagename eq chrome.exe""")
Set oExec = WshShell.Exec("taskkill /fi ""imagename eq firefox.exe""")
Set oExec = WshShell.Exec("taskkill /fi ""imagename eq opera.exe""")
Set oExec = WshShell.Exec("taskkill /fi ""imagename eq safari.exe""")
dim ObjShell
set ObjShell = CreateObject("WScript.Shell")
ObjShell.Run "CCleaner.exe /AUTO"
MsgBox "CCleaner is auto running"
'GFI MAX OutPut
If err.number <> 0 Then
WScript.Echo ("CCleaner Not Installed")
Wscript.Quit 1001
Else
WScript.Echo ("CCleaner Has Ran Successfully and may still be running")
Wscript.Quit 0
End If
Function UserInput( myPrompt )
' Check if the script runs in CSCRIPT.EXE
If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
' If so, use StdIn and StdOut
WScript.StdOut.Write myPrompt & " "
UserInput = WScript.StdIn.ReadLine
Else
' If not, use InputBox( )
UserInput = InputBox( myPrompt )
End If
End Function
ASKER
Yes I understand you could do that to get the LoginID.
The file would be named userswhohavecompleted.doc
And I would like it to appended to the same text file and yes on the same location the vbscript is being ran from. Date and Timestamp would be helpful so we know when it was done
The file would be named userswhohavecompleted.doc
And I would like it to appended to the same text file and yes on the same location the vbscript is being ran from. Date and Timestamp would be helpful so we know when it was done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Jacob,
Do you have enough to close this question now, or do you need more help?
~bp
Do you have enough to close this question now, or do you need more help?
~bp
What would the file be named?
What should the file contain, you mention username, anything else? Date / time stamp, any message, etc?
If the file exists, should it be appended to or overwritten?
One other thing I wanted to mention, it is possible in VBS to get the login id from Windows for the current user. SO rather than prompt them for a name which they could type anything, you could use their login id if that was useful, and get it automatically in the VBS with no prompting for it.
~bp