Does anyone know of something or someway to track who logs on to a server and for what reason. I have a script that takes down the username and time/date to a text file but is the also a way to prompt for a reason for access and write that as well?
Sorry I thought you already had it writting to a file. Here is the complete script to do all that you were asking. You need to switch this to a .VBS extension instead of a BAT.
reason = InputBox("Why are you accessing the server?","What are you trying to do Dave?")
Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("Wscript.Network")
report = WSHNetwork.Username & " accessed the server at "& Now & " for the following reason:" & vbCrLf
report = report & reason
Set ts = fso.CreateTextFile ("c:\reason.txt", ForAppending)
ts.write report
I hope you find this post helpful. Please let me know if it was.
Sorry about that. Forgot to define ForAppending. I added some error checking. This will fix it:
CONST ForAppending = 8
reason = InputBox("Why are you accessing the server?","What are you trying to do Dave?")
Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("Wscript.Network")
report = WSHNetwork.Username & " accessed the server at "& Now & " for the following reason:" & vbCrLf
report = report & reason & vbCrLf
If Not fso.FileExists("c:\reason.txt") Then
fso.CreateTextFile ("c:\reason.txt")
End If
Set ts = fspenTextFile ("c:\reason.txt", ForAppending)
ts.write report
I hope you find this post helpful. Please let me know if it was.
I added your line and it's giving me an error say object required WSHNETWORk
Here is the script:
ONST ForAppending = 8
reason = InputBox("Why are you accessing the server? Please give a reason. note: A blank response will be questioned by OMNB management!","Authorized Personnel Only!!!!")
WSHNetwork.MapNetworkDrive "w:", "\\*******\********",True
Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("Wscript.Network")
report = WSHNetwork.Username & " accessed the server at "& Now & " for the following reason:" & vbCrLf
report = report & reason & vbCrLf
If Not fso.FileExists("w:\sunshineserverlogin.txt") Then
fso.CreateTextFile ("w:\serverlogin.txt")
End If
Set ts = fspenTextFile ("w:\sunshineserverlogin.txt", ForAppending)
ts.write report
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.