远程锁定计算机



有什么方法可以远程锁定台式计算机吗?例如,如果一个人不小心让计算机登录,是否有办法使用远程连接 (VPN) 锁定该计算机?

使用 PsExec 调用:

rundll32.exe user32.dll, LockWorkStation

在远程电脑上。

如果您当前在PC_A上并且想要锁定PC_B,请在命令行(在PC_A上)键入以下内容:

psexec \PC_B -u user -p pass "rundll32.exe user32.dll, LockWorkStation"

这样rundll32.exe user32.dll, LockWorkStation将在PC_B上调用。

您可以使用任意名称创建文件,后缀 bat 在 bat 文件中使用此代码

rundll32.exe user32.dll, LockWorkStation

保存并运行

您可以使用 SysInternal 工具,主要是 PsShutdown 工具。您将在PC上获得cmd的实例并执行锁定命令。

例:

psshutdown \computername -l
Option Explicit
Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe, strInput
strExe = "rundll32.exe user32.dll,LockWorkStation"
' Input Box to get name of machine to run the process
Do
strComputer = (InputBox(" ComputerName to Run Script",_
"Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Loop until strInput = True
' Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
'WScript.echo "Created: " & strExe & " on " & strComputer
WSCript.Quit
' End of Example of a Process VBScript

最新更新