captedgar Posted August 12, 2010 Share Posted August 12, 2010 Hi there, i have created a Installer Script to install a patch to an application on a remote machine. My Installer script is as follows ; Run the Software1 Patch installer Run("SoftwarePatch-1.0.15.0-install.exe") ; Initial Setup Screen WinWaitActive("Patch Setup", "&Next >") Send("!n") ; License Agreement WinWaitActive("Patch Setup ", "I &Agree") Send("{ENTER}") ; Install location WinWaitActive("Patch Setup ", "&Install") Send("{ENTER}") ; SetUp Complete WinWaitActive("Patch Setup ", "Setup was completed successfully.") Send("!n") ; Activate User Manual WinWaitActive("Patch Setup ", "User Manual") Send("{-}") Send("{ENTER}") This Installer Script has been compiled into an .exe called AutoPatchInstaller.exe I have a batch file which calls the above .exe to perform my task @echo off for /F "usebackq delims==" %%I in ("servers.txt") do Call :begin %%I goto :EOF :begin set srv=%1 :get info echo Copying Patch Files to %srv% pause start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe when i run the batch file, for some strange reason, the batch file is installing on my local machine rather than on the remote machine which is listed in "servers.txt". Btw "servers.txt" is a text file having the list of remote machine name to which i want to perform the task. If i log onto remote machine and double click AutoPatchInstaller.exe, it works fine but can't get it working of the batch file. My question is, when i compiled the Installer Script to AutoPatchInstaller.exe should i have added somemore code in it to automatically run when i called it in a batch file? Please advice coz i have also tried doing it by adding a Psexec tool code in my batch file like following and i still can't get it to work \\<local machine>\c$\ReleaseFolder\psexec.exe \\%srv% /i "c:\Software1PatchInstall\AutoPatchInstaller.exe" Link to comment Share on other sites More sharing options...
MrMitchell Posted August 12, 2010 Share Posted August 12, 2010 (edited) In your batch, "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe" causes the exe to run on your system, but it's running the exe located on the remote system... If you use psexec, you should check your syntax (I think you need -i instead of /i, or it might not even matter), you might need more switches (such as the remote username -u and password -p to use, otherwise you may get permission errors), ... psexec also has the ability to both copy the file you want to run to the remote machine then run it, and execute the same command on a list of hosts (the parameter is @file). How large is the file "SoftwarePatch-1.0.15.0-install.exe"? and is it already located on all of your remote systems? Edited August 12, 2010 by MrMitchell Link to comment Share on other sites More sharing options...
captedgar Posted August 12, 2010 Author Share Posted August 12, 2010 In your batch, "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe" causes the exe to run on your system, but it's running the exe located on the remote system...If you use psexec, you should check your syntax (I think you need -i instead of /i, or it might not even matter), you might need more switches (such as the remote username -u and password -p to use, otherwise you may get permission errors), ...psexec also has the ability to both copy the file you want to run to the remote machine then run it, and execute the same command on a list of hosts (the parameter is @file).How large is the file "SoftwarePatch-1.0.15.0-install.exe"? and is it already located on all of your remote systems?Thanks for your reply MrMitchellSoftwarePatch-1.0.15.0-install.exe is about 2MB. In the batch file above, before running the "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe", there is a line of code which copies these files across to all the remote machines using psexec command.When u say "In your batch, "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe" causes the exe to run on your system, but it's running the exe located on the remote system..."does that mean that the exe is actually installing the patch on the remote machine? coz i've checked the add remove programs on the remote machine and it doesn't appear in the list.Also i'm on admin on all the remote box, so would permissions still be an issue?i've tried a variety of psexec commands to auto run the AutoPatchInstaller.exe but to no availsome of the commands i've tried is as followspsexec \\%srv% -i "cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENT"psexec \\%srv% -w "c:\Software1PatchInstall\"AutoPatchInstaller.exe /SILENT"psexec \\%srv% -w c:\Software1PatchInstall\ cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENTpsexec \\%srv% -i -w c:\Software1PatchInstall cmd.exe /c c:\Software1PatchInstall\SilentSetup.bat where SilentSetup.bat is AutoPatchInstaller.exe /SILENTplease advice Link to comment Share on other sites More sharing options...
captedgar Posted August 13, 2010 Author Share Posted August 13, 2010 Thanks for your reply MrMitchellSoftwarePatch-1.0.15.0-install.exe is about 2MB. In the batch file above, before running the "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe", there is a line of code which copies these files across to all the remote machines using psexec command.When u say "In your batch, "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe" causes the exe to run on your system, but it's running the exe located on the remote system..."does that mean that the exe is actually installing the patch on the remote machine? coz i've checked the add remove programs on the remote machine and it doesn't appear in the list.Also i'm on admin on all the remote box, so would permissions still be an issue?i've tried a variety of psexec commands to auto run the AutoPatchInstaller.exe but to no availsome of the commands i've tried is as followspsexec \\%srv% -i "cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENT"psexec \\%srv% -w "c:\Software1PatchInstall\"AutoPatchInstaller.exe /SILENT"psexec \\%srv% -w c:\Software1PatchInstall\ cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENTpsexec \\%srv% -i -w c:\Software1PatchInstall cmd.exe /c c:\Software1PatchInstall\SilentSetup.bat where SilentSetup.bat is AutoPatchInstaller.exe /SILENTplease advicei have also tried, psexec \\%srv% -i c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENT Link to comment Share on other sites More sharing options...
MrMitchell Posted August 13, 2010 Share Posted August 13, 2010 (edited) Thanks for your reply MrMitchell SoftwarePatch-1.0.15.0-install.exe is about 2MB. In the batch file above, before running the "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe", there is a line of code which copies these files across to all the remote machines using psexec command. Ok since SoftwarePatch-1.0.15.0-install.exe is only 2MB, try wrapping it in your script using FileInstall() command. Look it up in the help file for usage. Basically using that command will include the file in your script, then when the script runs it will unpack that file into the directory you specify (target directory you should use would be "C:\Software1PatchInstall\") in the FileInstall command. Going this route, you won't have to manually copy it to every machine beforehand...you would only have to copy your script's EXE over (which psexec.exe can do - see below) When u say "In your batch, "start \\%srv%\c$\Software1PatchInstall\AutoPatchInstaller.exe" causes the exe to run on your system, but it's running the exe located on the remote system..." does that mean that the exe is actually installing the patch on the remote machine? coz i've checked the add remove programs on the remote machine and it doesn't appear in the list. Also i'm on admin on all the remote box, so would permissions still be an issue? It means the patch is installing on the machine you ran the command on, but it's using the patch EXE which resides on the remote machine. Basically it's installing the patch off the network, which isn't your intention. i've tried a variety of psexec commands to auto run the AutoPatchInstaller.exe but to no avail some of the commands i've tried is as follows psexec \\%srv% -i "cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENT" psexec \\%srv% -w "c:\Software1PatchInstall\"AutoPatchInstaller.exe /SILENT" psexec \\%srv% -w c:\Software1PatchInstall\ cmd.exe /c c:\Software1PatchInstall\AutoPatchInstaller.exe /SILENT psexec \\%srv% -i -w c:\Software1PatchInstall cmd.exe /c c:\Software1PatchInstall\SilentSetup.bat where SilentSetup.bat is AutoPatchInstaller.exe /SILENT Here's the psexec usage (any options we aren't using have been removed to make it more readable): PsExec executes a program on a remote system, where remotely executed console applications execute interactively. Usage: psexec [@file][-u user [-p psswd]][-i ][-c [-f|-v]][-w directory] cmd @file PsExec will execute the command on each of the computers listed in the file (use servers.txt) -u Specifies optional user name for login to remote computer. -p Specifies optional password for user name. -i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session. -c Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system. -f Copy the specified program even if the file already exists on the remote system. -v Copy the specified file only if it has a higher version number or is newer on than the one on the remote system. -w Set the working directory of the process (relative to remote computer). cmd Name of application to execute. You can enclose applications that have spaces in their name with quotation marks e.g. psexec [url="file://marklap/"]\\marklap[/url] "c:\long name app.exe". Input is only passed to the remote system when you press the enter key, and typing Ctrl-C terminates the remote process. If you omit a user name the process will run in the context of your account on the remote system, but will not have access to network resources (because it is impersonating). Specify a valid user name in the Domain\User syntax if the remote process requires access to network resources or to run in a different account. Note that the password is transmitted in clear text to the remote system. Using that...build the psexec command: psexec @servers.txt -u domain\user -p password -i -c -v -w C:\Software1PatchInstall AutoPatchInstaller.exe "@servers.txt" is the file which contains the list of servers you want to run this command against "-u domain\user" is the user you'll be running as "-p password" is the password for above user "-i" run it interactively, need this for the script to actually work instead of just reside in memory doing nothing "-c" copy the file you want to run over to the remote machine before running it (the file being your latest and greatest AutoIt script) "-v" copy the above file to remote machine only if it's newer, otherwise don't do anything if it's already copied "-w C:\Software1PatchInstall" this is the working directory on the remote system, hopefully this is where your AutoIt script will be copied "AutoPatchInstaller.exe" the file we want to first copy to remote system, then run it. I hope all this makes sense. Since I don't have an ideal testing enviornment, that psexec command may not work properly or at all, so it'll need some tweaking. But I'm here to help if I can...good luck Edited August 13, 2010 by MrMitchell Link to comment Share on other sites More sharing options...
captedgar Posted August 14, 2010 Author Share Posted August 14, 2010 Thanks for your reply Mitchell I've tried as advised by you. I still get psexec error saying parameter is incorrect Find below my edited Installer script and also psexec command Installer script: $b = True If $b = True Then FileInstall("C:\TestFolder\SoftwarePatch-1.0.15.0-install.exe", "C:\Software1PatchInstall\") ; Run the Software1 Patch installer Run("SoftwarePatch-1.0.15.0-install.exe") ; Initial Setup Screen WinWaitActive("Patch Setup", "&Next >") Send("!n") ; License Agreement WinWaitActive("Patch Setup ", "I &Agree") Send("{ENTER}") ; Install location WinWaitActive("Patch Setup ", "&Install") Send("{ENTER}") ; SetUp Complete WinWaitActive("Patch Setup ", "Setup was completed successfully.") Send("!n") ; Activate User Manual WinWaitActive("Patch Setup ", "User Manual") Send("{-}") Send("{ENTER}") psexec command: psexec @servers.txt -u domain\user -p password -i -c -v -w C:\Software1PatchInstall AutoPatchInstaller.exe I get 2 errors on psexec. 1 is parameter is incorrect and the other being system cannot find the file specified. I have also tried the following i.e. psexec \\%srv% -u domain\user -p password -i -c -v -w C:\Software1PatchInstall\ AutoPatchInstaller.exe And i now get 1 error i.e. parameter is incorrect I have entered the correct domain username and password on both occasions please advice Ok since SoftwarePatch-1.0.15.0-install.exe is only 2MB, try wrapping it in your script using FileInstall() command. Look it up in the help file for usage. Basically using that command will include the file in your script, then when the script runs it will unpack that file into the directory you specify (target directory you should use would be "C:\Software1PatchInstall\") in the FileInstall command. Going this route, you won't have to manually copy it to every machine beforehand...you would only have to copy your script's EXE over (which psexec.exe can do - see below) It means the patch is installing on the machine you ran the command on, but it's using the patch EXE which resides on the remote machine. Basically it's installing the patch off the network, which isn't your intention. Here's the psexec usage (any options we aren't using have been removed to make it more readable): PsExec executes a program on a remote system, where remotely executed console applications execute interactively. Usage: psexec [@file][-u user [-p psswd]][-i ][-c [-f|-v]][-w directory] cmd @file PsExec will execute the command on each of the computers listed in the file (use servers.txt) -u Specifies optional user name for login to remote computer. -p Specifies optional password for user name. -i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session. -c Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system. -f Copy the specified program even if the file already exists on the remote system. -v Copy the specified file only if it has a higher version number or is newer on than the one on the remote system. -w Set the working directory of the process (relative to remote computer). cmd Name of application to execute. You can enclose applications that have spaces in their name with quotation marks e.g. psexec [url="file://marklap/"]\\marklap[/url] "c:\long name app.exe". Input is only passed to the remote system when you press the enter key, and typing Ctrl-C terminates the remote process. If you omit a user name the process will run in the context of your account on the remote system, but will not have access to network resources (because it is impersonating). Specify a valid user name in the Domain\User syntax if the remote process requires access to network resources or to run in a different account. Note that the password is transmitted in clear text to the remote system. Using that...build the psexec command: psexec @servers.txt -u domain\user -p password -i -c -v -w C:\Software1PatchInstall AutoPatchInstaller.exe "@servers.txt" is the file which contains the list of servers you want to run this command against "-u domain\user" is the user you'll be running as "-p password" is the password for above user "-i" run it interactively, need this for the script to actually work instead of just reside in memory doing nothing "-c" copy the file you want to run over to the remote machine before running it (the file being your latest and greatest AutoIt script) "-v" copy the above file to remote machine only if it's newer, otherwise don't do anything if it's already copied "-w C:\Software1PatchInstall" this is the working directory on the remote system, hopefully this is where your AutoIt script will be copied "AutoPatchInstaller.exe" the file we want to first copy to remote system, then run it. I hope all this makes sense. Since I don't have an ideal testing enviornment, that psexec command may not work properly or at all, so it'll need some tweaking. But I'm here to help if I can...good luck Link to comment Share on other sites More sharing options...
captedgar Posted August 16, 2010 Author Share Posted August 16, 2010 The parameter incorrect error is inconsistant though Link to comment Share on other sites More sharing options...
MrMitchell Posted August 16, 2010 Share Posted August 16, 2010 It's been a while since I've used psexec so I knew my command wouldn't work as written...you'll need to start out small and make your way toward a working command. You can try removing the space between the switch and parameter, for example: Instead of -u Domain\Username -p Password...try: -uDomain\Username -pPassword I think psexec requires certain Windows services to be started on the remote machines, have you checked that too? Link to comment Share on other sites More sharing options...
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