我被一个我一直使用了几年的脚本的作者指向了这个方向。在Windows下远程锁定屏幕的脚本7
它允许桌面的远程锁定,并在Windows XP本地和远程工作正常,并在本地的Windows 7下正常工作,但尝试远程使用它反对无法工作在Windows 7机器的时候。 这已经很棒了几年了,并且非常有用,但是我们最近开始在现场部署Windows 7计算机,一旦升级完全完成,我将无法再使用它。
,我已经提出了一个几年前,但无人接听的same question。
下面是VBS代码:
' StartProcess.vbs
' Sample VBScript to start a process. Inputbox for name
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.2 - December 2005
' -------------------------------------------------------'
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
(HTTP [那VBS代码从未真正摆在首位 “工作”]://blogs.msdn。 COM/b/oldnewthing /存档/ 2004/01/15/58973.aspx)。 Rundll32.exe从未打算调用'LockWorkStation'函数,因为它有错误的签名。现在和解决问题一样好。 – 2012-01-10 09:13:35
感谢您的链接和编辑科迪,我看到有人说,打电话给rundll32这不是一个好主意,但不明白为什么直到现在。 – 2012-01-10 09:20:29
@Cody Gray:LockWorkStation不需要任何参数,所以它不会介意rundll32.exe是否传递比所需参数多的参数。 – 2012-01-10 09:29:16