I am working on a script to lock remote computers, but I'm having a little trouble. When I run this script, nothing happens and there are no errors. Anyone see what am I doing wrong? If you know of a better way, I'm open to suggestions as well.
Code:
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
set colOS = objWMIService.InstancesOf("Win32_OperatingSystem")
Set WshShell = WScript.CreateObject("WScript.Shell")
For each objOS in colOS
strCommand = objOS.SystemDirectory & "\RunDll.exe"
next
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%comspec% " & strCommand & " user32.dll,LockWorkStation", 0, False