如何检查工作站是否已锁定?

时间:2021-09-05 16:45:19

Can anyone help with code snippet for checking if the workstation is locked? I tried with getting the document.title, so that when the workstation is locked it returns blank for document.title. This is not working.

任何人都可以帮助使用代码片段来检查工作站是否被锁定?我试着获取document.title,这样当工作站被锁定时,它会返回document.title的空白。这不起作用。

I am encoding wscript in vbscript which is residing in HTML.

我在vbscript中编码wscript,它驻留在HTML中。

Any help with Javascript is also fine.

任何有关Javascript的帮助也很好。

4 个解决方案

#1


Normally you should be using a wmi query to look at the event log's security log. Howver, XP doesn't have a lock event ids (vista/win7/2008 does have both lock and unlock event ids).

通常,您应该使用wmi查询来查看事件日志的安全日志。但是,XP没有锁定事件ID(vista / win7 / 2008确实同时具有锁定和解锁事件ID)。

XP DOES have an unlock event, event though. Most people don't realize the unlock event invovles BOTH a logon/logoff events (event ids 528/538, which occur at practically the same time). The Login Type will be EventType 7, and that's how you tell someone is unlocking the workstation. Login Type 7 (whether logon or logoff) is an unlock event.

XP DOES有一个解锁事件,但事件。大多数人都没有意识到解锁事件会同时发生登录/注销事件(事件ID 528/538,几乎在同一时间发生)。登录类型将是EventType 7,这就是您告诉某人解锁工作站的方式。登录类型7(无论是登录还是注销)是解锁事件。

For Vista/Win7/2008 the new workstation lock event id is 4800 wile the updated way of determining an unlock event is event id 4801. However, the source log in post Vista OSes is not the Security log, but the Microsoft-Windows-Security-Auditing log.

对于Vista / Win7 / 2008,新的工作站锁定事件ID为4800,确定解锁事件的更新方式是事件ID 4801.但是,Vista后操作系统中的源日志不是安全日志,而是Microsoft-Windows-Security - 审核日志。

If you have Win7 your in luck, and should just write a wmi query. XP, I can't see a good way of doing it, unless you want to try idle time.

如果你有Win7,你应该写一个wmi查询。 XP,我看不出这样做的好方法,除非你想尝试空闲时间。

#2


One indicator that works (on Windows 7 SP1 with a single user and no remote desktop) is to check for the presence of the LogonUI.exe process, which is only there when the workstation is locked. See the following islocked.vbs, which can also be passed a remote computer name.

一个有效的指示器(在具有单个用户但没有远程桌面的Windows 7 SP1上)是检查是否存在LogonUI.exe进程,该进程仅在工作站被锁定时才存在。请参阅以下islocked.vbs,它也可以传递远程计算机名称。

' Source:
'   http://community.spiceworks.com/scripts/show/1965-detect-screen-lock-status
Dim computer : computer = "."
If WScript.Arguments.Count = 1 Then
    computer = WScript.Arguments(0)
End If

Function IsWorkstationLocked( computer )
    Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2")
    Dim logonScreenCount : logonScreenCount = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'LogonUI.exe'").Count

    IsWorkstationLocked = (logonScreenCount > 0)
End Function

If IsWorkstationLocked(computer) Then
    WScript.Quit(0)
Else
    WScript.Quit(1)
End If

#3


Not sure you can check the through a script. Most functions will run as expected. One thing that wouldn't work is sending keys (simulating key press or mouse moves), but you cannot do it from a script on html.
Perhaps you can check instead for idle time since the user's last activity?

不确定您是否可以通过脚本查看。大多数功能将按预期运行。一件不起作用的是发送密钥(模拟按键或鼠标移动),但你不能通过html上的脚本来完成。也许您可以检查自用户上次活动以来的空闲时间?

#4


If there is a screensaver you may see a process like 'logon.scr'. That won't work though if you don't have the screensaver running. It is pretty easy with .Net though using this code.

如果有屏幕保护程序,您可能会看到像'logon.scr'这样的过程。如果您没有运行屏幕保护程序,那将无效。使用此代码时,.Net很容易。

You could create that as a COM object and call it from VBScript.

您可以将其创建为COM对象并从VBScript中调用它。

#1


Normally you should be using a wmi query to look at the event log's security log. Howver, XP doesn't have a lock event ids (vista/win7/2008 does have both lock and unlock event ids).

通常,您应该使用wmi查询来查看事件日志的安全日志。但是,XP没有锁定事件ID(vista / win7 / 2008确实同时具有锁定和解锁事件ID)。

XP DOES have an unlock event, event though. Most people don't realize the unlock event invovles BOTH a logon/logoff events (event ids 528/538, which occur at practically the same time). The Login Type will be EventType 7, and that's how you tell someone is unlocking the workstation. Login Type 7 (whether logon or logoff) is an unlock event.

XP DOES有一个解锁事件,但事件。大多数人都没有意识到解锁事件会同时发生登录/注销事件(事件ID 528/538,几乎在同一时间发生)。登录类型将是EventType 7,这就是您告诉某人解锁工作站的方式。登录类型7(无论是登录还是注销)是解锁事件。

For Vista/Win7/2008 the new workstation lock event id is 4800 wile the updated way of determining an unlock event is event id 4801. However, the source log in post Vista OSes is not the Security log, but the Microsoft-Windows-Security-Auditing log.

对于Vista / Win7 / 2008,新的工作站锁定事件ID为4800,确定解锁事件的更新方式是事件ID 4801.但是,Vista后操作系统中的源日志不是安全日志,而是Microsoft-Windows-Security - 审核日志。

If you have Win7 your in luck, and should just write a wmi query. XP, I can't see a good way of doing it, unless you want to try idle time.

如果你有Win7,你应该写一个wmi查询。 XP,我看不出这样做的好方法,除非你想尝试空闲时间。

#2


One indicator that works (on Windows 7 SP1 with a single user and no remote desktop) is to check for the presence of the LogonUI.exe process, which is only there when the workstation is locked. See the following islocked.vbs, which can also be passed a remote computer name.

一个有效的指示器(在具有单个用户但没有远程桌面的Windows 7 SP1上)是检查是否存在LogonUI.exe进程,该进程仅在工作站被锁定时才存在。请参阅以下islocked.vbs,它也可以传递远程计算机名称。

' Source:
'   http://community.spiceworks.com/scripts/show/1965-detect-screen-lock-status
Dim computer : computer = "."
If WScript.Arguments.Count = 1 Then
    computer = WScript.Arguments(0)
End If

Function IsWorkstationLocked( computer )
    Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2")
    Dim logonScreenCount : logonScreenCount = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'LogonUI.exe'").Count

    IsWorkstationLocked = (logonScreenCount > 0)
End Function

If IsWorkstationLocked(computer) Then
    WScript.Quit(0)
Else
    WScript.Quit(1)
End If

#3


Not sure you can check the through a script. Most functions will run as expected. One thing that wouldn't work is sending keys (simulating key press or mouse moves), but you cannot do it from a script on html.
Perhaps you can check instead for idle time since the user's last activity?

不确定您是否可以通过脚本查看。大多数功能将按预期运行。一件不起作用的是发送密钥(模拟按键或鼠标移动),但你不能通过html上的脚本来完成。也许您可以检查自用户上次活动以来的空闲时间?

#4


If there is a screensaver you may see a process like 'logon.scr'. That won't work though if you don't have the screensaver running. It is pretty easy with .Net though using this code.

如果有屏幕保护程序,您可能会看到像'logon.scr'这样的过程。如果您没有运行屏幕保护程序,那将无效。使用此代码时,.Net很容易。

You could create that as a COM object and call it from VBScript.

您可以将其创建为COM对象并从VBScript中调用它。