Hello everyone. Please help me on this one! I'm trying to make a VBScript that checks whether or not a specific user is loggen on. If not, send smtp warning email. This should be fairly simple, but I can't get anything to work.
The code is:
'VBScript: Check to see, whether or not UserName is loggen on
'If logged on, do nothing. If not logged on, send warning email
Code:Dim oShell Dim callingUser Dim userName Set userName = "example.user" Set oShell = Wscript.CreateObject("Wscript.Shell") callingUser = oShell.ExpandEnvironmentStrings("%USERNAME%") 'WScript.Echo callingUser 'HELP me write a boolean function that checks to see whether or not userName is currently loggen on 'Returns true if userName is logged on, false if not. if(loggedOn = true) then Set oMsg = CreateObject("CDO.Message") set iBodyPart = oMsg.BodyPart iBodyPart.CharSet = "iso-8859-1" oMsg.To = "[email protected]" oMsg.From = "[email protected]" oMsg.Subject = "WARNING from " & callingUser & ": " & userName & " is not logged on." oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "HIDDEN" oMsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 oMsg.Configuration.Fields.Update oMsg.Send Set oMsg = Nothing end if




Reply With Quote