我被一個我一直使用了幾年的腳本的作者指向了這個方向。在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