Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to lock computer

Status
Not open for further replies.

FloDiggs

MIS
Jan 20, 2007
296
US
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
 
Figured it out. I needed to have RunDll32.exe, not RunDll.exe. Simple typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top