Mikie Posted April 26, 2007 Posted April 26, 2007 I have created a script that will install an application. I compile the code. I then copy the code (answer file) to a remote machine along with the original install.exe. I can't get the code to install on the remote machine. But it launches on the local machine I launch the code on. Here are the two scripts. Whatever insight you could give me would be great!Creates dir, copies files: filename = VisioInst.exeDirCreate("\\machinename\C$\Program files\VisioInst")FileInstall("c:\Code\Scripts\AutoIT\VisioViewer\Visio_a.exe", "\\machinename\C$\Program files\VisioInst\Visio_a.exe")FileInstall("c:\Code\Scripts\AutoIT\VisioViewer\VViewer.exe", "\\machinename\C$\Program files\VisioInst\VViewer.exe")Run("\\machinename\C$\Program files\VisioInst\Visio_a.exe") This is where it bombs!(Should) Launch install on remote machine: filename = Visio_a.exeRun("vviewer.exe", "\\machinename\C$\Program files\VisioInst")WinWait("Visio Viewer","")$CLVItem = ControlListView("Visio Viewer","","SysListView321","FindItem","vviewer.exe")ControlListView("Visio Viewer","","SysListView321","SelectClear")ControlListView("Visio Viewer","","SysListView321","Select",$CLVItem)$CLVItem = ControlListView("Visio Viewer","","SysListView321","FindItem","vviewer.exe")ControlListView("Visio Viewer","","SysListView321","SelectClear")ControlListView("Visio Viewer","","SysListView321","Select",$CLVItem)WinWait("Microsoft Office Visio Viewer 2003 Setup","I &accept the terms in the Lic")ControlCommand("Microsoft Office Visio Viewer 2003 Setup","I &accept the terms in the Lic","Button1","Check","")Send("!I")WinWait("Microsoft Office Visio Viewer 2003 Setup","The readme file provides addit")ControlClick("Microsoft Office Visio Viewer 2003 Setup","The readme file provides addit","Button2")
Teldin Posted April 26, 2007 Posted April 26, 2007 I think you'll need to use something like psexec.exe. Google for it.
herewasplato Posted April 26, 2007 Posted April 26, 2007 (edited) See FAQ:Q9. How can I run my script on a remote computer over the network?http://www.autoitscript.com/forum/index.ph...st&p=253174it has the PsExec link that Teldin mentioned.-MSP- Edited April 27, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
lordofthestrings Posted April 27, 2007 Posted April 27, 2007 look, to run applications remotely you need to use WMI .. (forget PSEXEC when you have autoIT ) only thing you can come across that might be problematic is the fact that the userprofile doesnt get loaded before execution of the command, which will mean to you that you will see the application running in taskmanager, but it wont popup a new window.. this fnc you can use like this RemoteExecute($strComputer, $CommandLine) expandcollapse popupfunc RemoteExecute($strComputer, $CommandLine) ; Simple $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $objShare = $objWMIService.Get("Win32_Process") $objInParam = $objShare.Methods_("Create").inParameters.SpawnInstance_() $objInParam.Properties_.Item("CommandLine") = $CommandLine $objOutParams = $objWMIService.ExecMethod("Win32_Process", "Create", $objInParam) $PID = $objOutParams.ProcessId $ReturnValue = $objOutParams.ReturnValue Switch $ReturnValue Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$strComputer: " & $strComputer & @CRLF & _ "$CommandLine: " & $CommandLine) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $ReturnValue) EndSwitch EndFunc oÝ÷ ÚØb²ÞÊj{¬z'ò¢èZ½æ¥µêçj×ç^ØÇâX§¶¯j¸nW¬jëh×6Func RemoteExecuteAdvanced() global $Hostname,$Application,$WorkingDirectory,$User,$Password $Locator = ObjCreate("WbemScripting.SWbemLocator") $Service = $Locator.ConnectServer($Hostname,"root/cimv2",$User,$Password) $Security = $Service.Security_ $Security.ImpersonationLevel = 3 $Class = $Service.Get("Win32_Process") If $WorkingDirectory == "" then $Result = $Class.Create($Application) ;no working directory specified Else $Result = $Class.Create($Application,$WorkingDirectory) EndIf ; $Class.close ; $Security.close ; $Service.close ; $Locator.close Switch $Result Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$Hostname: " & $Hostname & @CRLF & _ "$Application: " & $Application & @CRLF & _ "$WorkingDirectory: " & $WorkingDirectory & @CRLF & _ "$User: " & $User & @CRLF & _ "$Password: " & $Password) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $Result) EndSwitch EndFunc
Mikie Posted April 27, 2007 Author Posted April 27, 2007 See FAQ:Q9. How can I run my script on a remote computer over the network?http://www.autoitscript.com/forum/index.ph...st&p=253174it has the PsExec link the Teldin mentioned.-MSP-
Mikie Posted April 27, 2007 Author Posted April 27, 2007 Thanks for the heads up. I never think to go to the FAQ's.
Mikie Posted April 27, 2007 Author Posted April 27, 2007 look, to run applications remotely you need to use WMI .. (forget PSEXEC when you have autoIT ) only thing you can come across that might be problematic is the fact that the userprofile doesnt get loaded before execution of the command, which will mean to you that you will see the application running in taskmanager, but it wont popup a new window.. this fnc you can use like this RemoteExecute($strComputer, $CommandLine) expandcollapse popupfunc RemoteExecute($strComputer, $CommandLine) ; Simple $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $objShare = $objWMIService.Get("Win32_Process") $objInParam = $objShare.Methods_("Create").inParameters.SpawnInstance_() $objInParam.Properties_.Item("CommandLine") = $CommandLine $objOutParams = $objWMIService.ExecMethod("Win32_Process", "Create", $objInParam) $PID = $objOutParams.ProcessId $ReturnValue = $objOutParams.ReturnValue Switch $ReturnValue Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$strComputer: " & $strComputer & @CRLF & _ "$CommandLine: " & $CommandLine) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $ReturnValue) EndSwitch EndFunc oÝ÷ ÚØb²ÞÊj{¬z'ò¢èZ½æ¥µêçj×ç^ØÇâX§¶¯j¸nW¬jëh×6Func RemoteExecuteAdvanced() global $Hostname,$Application,$WorkingDirectory,$User,$Password $Locator = ObjCreate("WbemScripting.SWbemLocator") $Service = $Locator.ConnectServer($Hostname,"root/cimv2",$User,$Password) $Security = $Service.Security_ $Security.ImpersonationLevel = 3 $Class = $Service.Get("Win32_Process") If $WorkingDirectory == "" then $Result = $Class.Create($Application) ;no working directory specified Else $Result = $Class.Create($Application,$WorkingDirectory) EndIf ; $Class.close ; $Security.close ; $Service.close ; $Locator.close Switch $Result Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$Hostname: " & $Hostname & @CRLF & _ "$Application: " & $Application & @CRLF & _ "$WorkingDirectory: " & $WorkingDirectory & @CRLF & _ "$User: " & $User & @CRLF & _ "$Password: " & $Password) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $Result) EndSwitch EndFunc
mattw112 Posted December 9, 2008 Posted December 9, 2008 I'm trying to use this function (see below) but I'm getting an error that "the requested action with this object has failed", any ideas? Am I doing something wrong? The machine I'm trying to do this to is in a workgroup. Thanks, Terry expandcollapse popup$Hostname="GATEWAYT6828" $Application="shutdown.exe -s -f -t 60" $WorkingDirectory="c:\windows\system32" $User="GATEWAYT6828\Microsoft" $Password="pass@word1" RemoteExecuteAdvanced() Func RemoteExecuteAdvanced() global $Hostname,$Application,$WorkingDirectory,$User,$Password $Locator = ObjCreate("WbemScripting.SWbemLocator") $Service = $Locator.ConnectServer($Hostname,"root/cimv2",$User,$Password) $Security = $Service.Security_ $Security.ImpersonationLevel = 3 $Class = $Service.Get("Win32_Process") If $WorkingDirectory == "" then $Result = $Class.Create($Application) ;no working directory specified Else $Result = $Class.Create($Application,$WorkingDirectory) EndIf ; $Class.close ; $Security.close ; $Service.close ; $Locator.close Switch $Result Case 0 msgbox(0, "RunRemote","The remote command completed successfully") Case 2 msgbox(0, "RunRemote","Answer from Remote Computer: Access denied") Case 3 msgbox(0, "RunRemote","Insufficient privilege to launch remote command") Case 8 msgbox(0, "RunRemote","Unknown failure") Case 9 msgbox(0, "RunRemote","Path not found") Case 21 msgbox(0, "RunRemote","Invalid parameter passed to script: " & @CRLF & _ "$Hostname: " & $Hostname & @CRLF & _ "$Application: " & $Application & @CRLF & _ "$WorkingDirectory: " & $WorkingDirectory & @CRLF & _ "$User: " & $User & @CRLF & _ "$Password: " & $Password) Case Else msgbox(0, "RunRemote","Unknown error" & @CRLF & _ "ResultCode: " & $Result) EndSwitch EndFunc
Danny35d Posted December 9, 2008 Posted December 9, 2008 (edited) The following variable belong to the main part of the script and not to RemoteExecuteAdvanced() function. If you want to use them with RemoteExecuteAdvanced() function you need to add Global at the beginning of the variable. Ex($Hostname="GATEWAYT6828" change it to Global $Hostname="GATEWAYT6828") $Hostname="GATEWAYT6828" $Application="shutdown.exe -s -f -t 60" $WorkingDirectory="c:\windows\system32" $User="GATEWAYT6828\Microsoft" $Password="pass@word1" Edited December 9, 2008 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
someone Posted December 10, 2008 Posted December 10, 2008 (edited) I had been using Psexec to run a very simple program to monitor the existance of a window on a remote machine. The code I'm executing is just; If WinExists(" Done") Then Exit(0) ;good Else Exit(1) ;bad EndIf Psexec will tell me the return code of the exe (0 or 1), so I can use a local script to monitor that output. How can I use the RemoteExecuteAdvanced method and still nab the exe's return value? Or better how can I use wmi to list the open windows of a remote machine? Thanks EDIT: Forgot to say I'm using the -i option in psexec. Looks like this psexec \\computer -u User -p Password -i -c test.exe Edited December 11, 2008 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd
someone Posted December 11, 2008 Posted December 11, 2008 The more I read on this it doesn't sound possible and that psexec is the best option, but I'm still curious, hence a bump. While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd
mattw112 Posted December 17, 2008 Posted December 17, 2008 So I gave up on the WMI remote query... hopefully some day someone else will have a solution. Instead I just manually went around to the 200 systems and ran the script locally. BUT I also have another script I'm now using to do things on those machines using PSEXEC. To get psexec to work on Vista, there were several things I had to do on the machines. There's a registry key that needs to be set and a port that needs to be open ( port 445) Reg key is: RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system", "LocalAccountTokenFilterPolicy", "REG_DWORD", "1") Thanks, Terry
Abhay Posted December 18, 2008 Posted December 18, 2008 Do we have a solution for this? Running a GUI automation script on remote computer?
jennico Posted March 13, 2009 Posted March 13, 2009 (edited) yes, it's possible.1st method : run Win32_Process Class by WMI (this does the script above by lordofthestrings). disadvantage: no gui on remote.2nd method : schedule the process as a task on remote by Win32_ScheduledJob Class (WMI). this will create a normal gui with the process.Source: How to execute program on remote computer?strComputer = "." strCommand = "notepad.exe" Const INTERVAL = "n" Const MINUTES = 1 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob") Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime") objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now())) errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID) If errReturn = 0 Then Wscript.Echo "notepad.exe was started with a process ID: " & intJobID Else Wscript.Echo "notepad.exe could not be started due to error: " & errReturn End If Edited March 13, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
herewasplato Posted March 14, 2009 Posted March 14, 2009 look, to run applications remotely you need to use WMI .. (forget PSEXEC when you have autoIT ) ...... Win32_Process Class by WMI ......... Win32_ScheduledJob Class (WMI). ...And if WMI is disabled on the remote computer - then stick with PsExec [size="1"][font="Arial"].[u].[/u][/font][/size]
jennico Posted March 14, 2009 Posted March 14, 2009 (edited) from the above script : $Security = $Service.Security_ $Security.ImpersonationLevel = 3oÝ÷ ÙªÞ¶¬zX§zÇ(®·µ«·r©ÝN'rv÷öÙbëazh§µêéëbazéÝz»¢·²X§yºÞjKzkhÂä~)Þnël¢g)àËìvêb笲Øqçb¶ÈhºWgßÛbµ·ºÚ"µÍIÌÍÓØØ]ÜHØÜX]J ][ÝÕØ[TØÜ[ËÕØ[SØØ]Ü][ÝÊBIÌÍÔÙXÙHH ÌÍÓØØ]ÜÛÛXÝÙ ÌÍÔÙ ][ÝÜÛÝØÚ[]][ÝË ÌÍÐ[Y[[[YK ÌÍÔÜÝÛÜ BNÉÌÍÔÙXÝ]HH ÌÍÔÙXÙKÙXÝ]WÂNÉÌÍÔÙXÝ]K[ÛÛ][Û][HÂIÌÍÔÙXÙKÙXÝ]WË[ÛÛ][Û][HÂIÌÍÐÛÜÈH ÌÍÔÙXÙKÙ] ][ÝÕÚ[ÌÔØÙÜÉ][ÝÊ or is it the same ? Edited March 14, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
Graywalker Posted April 21, 2009 Posted April 21, 2009 yes, it's possible. 2nd method : schedule the process as a task on remote by Win32_ScheduledJob Class (WMI). this will create a normal gui with the process. And in AutoIt3 code : Func RemoteExecute($strPCName, $CommandLine) Dim $objWMIService, $objscheduledJob, $objSWbemDateTime, $errReturn, $runtime, $intJobID $objWMIService = ObjGet("winmgmts:\\" & $strPCName & "\root\cimv2") $objScheduledJob = $objWMIService.Get("Win32_ScheduledJob") If @min > 55 Then $time = (@hour + 1) & ":01" & ":" & @SEC Else $time = @hour & ":" & (@min + 1) & ":" & @SEC EndIf $runtime = @mon & "/" & @MDAY & "/" & @YEAR & " " & $time $objSWbemDateTime = ObjCreate("WbemScripting.SWbemDateTime") $objSWbemDateTime.SetVarDate($runtime) $errReturn = $objScheduledJob.Create($CommandLine, $objSWbemDateTime.Value, False, 0, 0, True, $intJobID) If $errReturn = 0 Then FileWriteLine($LogFile, "Scheduled task was started with task ID: " & $intJobID) Else FileWriteLine($LogFile, "Scheduled task could not be started due to error: " & $errReturn) EndIf EndFunc Of course, if someone knows a simpler thing to do with the time... by all means.
spudw2k Posted April 21, 2009 Posted April 21, 2009 Also, WMI does not allow desktop interaction. You MUST use either a scheduled task or PSEXEC as to get it to run "interactively". Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
DeDee Posted September 29, 2014 Posted September 29, 2014 Hi I'm trying to create an autoit script to execute remotly some UI web tests. I tried the examples from this page, used psexec, and I was able to execute remotly the script BUT in kid of silent mode, no UI. I saw that the process was started, and remains opened.I don't see the tests being launched. Can you help with some suggestions? Thanks
Moderators JLogan3o13 Posted September 29, 2014 Moderators Posted September 29, 2014 dcalina, please do not resurrect old threads (especially after 5+ years). If you are running into an issue, please start a new thread, and provide a detailed description of what you are trying to accomplish, along with the code you are using (even if it is not working as you should) so we are not left to guess. I guarantee you, you will get many more eyes on the subject this way rather than replying to such an old thread. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now