说实话我还有其他方法,怕不通用,你确定你上边的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
|