|
|
发表于 2012-6-5 20:30:41
|
显示全部楼层
说实话我还有其他方法,怕不通用,你确定你上边的show不出界面吗?哈哈,非常感谢
- RemoteExecute("c:\windows\system32\calc.exe") ; This works - executes on local pc
- Func RemoteExecute($strProgToRun)
- Local $objWMIService, $objProcess, $objProgram
- $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
- If Not IsObj($objSWbemLocator) Then
- MsgBox(0, "Error", "Error: failed to create $objSWbemLocator")
- Exit
- EndIf
- $objWMI = $objSWbemLocator.ConnectServer(".", "root\cimv2") ; This works for remote pc if pass actual credentials and works for local if pass null credentials
- If Not IsObj($objWMI) Then
- MsgBox(0, "Error", "Error: failed to create $objWMI")
- Exit
- EndIf
- $objWMI.Security_.ImpersonationLevel = 3
- $objProcess = $objWMI.Get("Win32_Process")
- $objProgram = $objProcess.Methods_("Create").InParameters.SpawnInstance_
- $objProgram.CommandLine = $strProgToRun
- $objWMI.ExecMethod("Win32_Process", "Create", $objProgram) ; Execute the program now at the command line.
- EndFunc
复制代码 |
|