I am writing a script to capture the login time. In the final production, there would be no input from any user. However I am testing it and I wanted to know how I add extra code to determine that
- If its in ‘debug’ mode AND
- The user that is logging in is me (lets say my username is joe.smith on the domain called EXAMPLE)
then present an input box to allow me to type the date, time for logging in.
All other users would never see this and it would capture today with the system time.
I would also like to hide the code so if the script is opened by the wrong person, they wouldnt be able to make heads or tails of whats going on.
You can use a command line parameter as Matt says to set the script into debug mode, eg
Which you can invoke with
To get the current user name, you can use either the WMI Service or the
WScript.Networkobject.Once you have the username, you can conditionally throw up an
InputBoxand collect the value returned:And finally, to obfuscate your code you could use the
Scripting.Encoderalthough it looks like this doesn’t seem to be supported on Vista or Windows 7. There does seem to be a few hits on googling the phrase obfuscating vbscript, anyway.