I am trying to remotely log off from a server. I am using the following code:
Set objSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strcomputer & "\root\cimv2")_
.InstancesOf("Win32_OperatingSystem")
WScript.Echo "Starting to Log-Off"
For Each objSystem In objSystemSet
Wscript.Echo objSystem.Name
objSystem.Win32Shutdown 0
Next
WScript.Echo "Done..."
The code works for a local box, but does not work for any boxes that are on the network. Could it be security related issue or else? Is there a way to do this?
Set objSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strcomputer & "\root\cimv2")_
.InstancesOf("Win32_OperatingSystem")
WScript.Echo "Starting to Log-Off"
For Each objSystem In objSystemSet
Wscript.Echo objSystem.Name
objSystem.Win32Shutdown 0
Next
WScript.Echo "Done..."
The code works for a local box, but does not work for any boxes that are on the network. Could it be security related issue or else? Is there a way to do this?