您可以使用此VBScript了解工作站是否已锁定。。如果是的话,从它被锁起。
此脚本将检查进程
LogonUI.exe
它是在工作站被锁定时创建的,并获得该进程的创建日期。
Dim strReturn : strReturn = "."
Dim computer : computer = "."
If WScript.Arguments.Count = 1 Then
computer = WScript.Arguments(0)
End If
Function WMIDateStringToDate(dtmStart)
WMIDateStringToDate = CDate(Mid(dtmStart, 5, 2) & "/" & _
Mid(dtmStart, 7, 2) & "/" & Left(dtmStart, 4) _
& " " & Mid (dtmStart, 9, 2) & ":" & _
Mid(dtmStart, 11, 2) & ":" & Mid(dtmStart, 13, 2))
End Function
Function IsWorkstationLocked( computer )
Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2")
Dim logonScreenCount
Set logonScreenCount = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'LogonUI.exe'")
for each xxx in logonScreenCount
StartTime = xxx.CreationDate
strReturn = WMIDateStringToDate(StartTime)
creationTime = xxx.CreationDate
Next
IsWorkstationLocked = (logonScreenCount.Count > 0)
End Function
If IsWorkstationLocked(computer) Then
Wscript.Echo "locked since " & strReturn
Else
Wscript.Echo "not locked"
End If
嗯!