Friday, November 03, 2006

VB script to log off user

I tested this in a MOM environment as a automated response to a rule.  Basically if you monitor the event logs for event # : 538, and the user name: "Insert Username Here"  you can have this script run as a automated response to log them back off.
 
Enjoy!
 

' Connect to computer
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
' Actual logoff
for each OpSys in OpSysSet
 OpSys.Win32Shutdown 4
next
' Done
WScript.Quit(0)

No comments: