Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
If all the above are true, this script can tell you if the computer is locked; it does that by grabbing the executable file name for the screen saver, and then checking to see if that executable file is running (by looking at instances of the Win32_Process class). If the screensaver is running then, by definition, the computer must be locked:
strComputer = "." ;indicates the local machine strKeyPath = "Control Panel\Desktop" ValueName = "ScrnSave.exe" strValue = RegQueryValue( @REGCURRENT, StrCat(strKeyPath, '[', ValueName,']')) strValue = StrReplace(strValue, "\", "\\") objWMIService = GetObject(StrCat("winmgmts:\\" , strComputer , "\root\cimv2")) colItems = objWMIService.ExecQuery(StrCat("Select * From Win32_Process Where ExecutablePath ='" , strValue , "'")) If colItems.Count > 0 Then Message("Notice", "The computer is locked.") Else Message("Notice", "The computer is not locked.") End If
strKeyPath = "Control Panel\Desktop" ValueName = "ScrnSave.exe" strValue = RegQueryValue( @REGCURRENT, StrCat(strKeyPath, '[', ValueName,']')) ;Windows 2000/XP: Determines whether a screen saver is currently running on the ;window station of the calling process. Note that only the interactive window station, "WinSta0", can have a ;screen saver running. ;Value: (i) @TRUE if a screen saver is currently running, or @FALSE otherwise. ret = SysParamInfo( 114, 0, 0) If ret Message("Notice", "The computer is locked.") Else Message("Notice", "The computer is not locked.") End If
Article ID: W16989
File Created: 2007:07:03:14:27:30
Last Updated: 2007:07:03:14:27:30