如何使用 VBscript 检查计算机是否已被锁定?我想在计算机锁定后停止应用程序运行,并在计算机解锁后再次运行该应用程序
最佳答案
您可以尝试检查logonui.exe
进程是否存在。如果找到它,则计算机已锁定或未登录。
Function IsLocked(strComputer)
With GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
IsLocked = .ExecQuery("select * from Win32_Process where Name='logonui.exe'").Count > 0
End With
End Function
要测试本地计算机,请传递 PC 名称或句点。例如:
If IsLocked(".") Then MsgBox "Local computer is locked."
关于vbscript - 使用 VBscript 检查计算机是否被锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25580311/