antmar904 Posted April 18, 2018 Posted April 18, 2018 Hi I run a script that installed software on remote computers however this process takes some time because it will install the software one by one. Here is a quick example of the scriptlogic: 1) Read txt file with computer names 2) Ping each computer in the txt file 3) If the computer is pingable 3a) Copy the installation files to the computer 3b) Run the installation and wait until it's done (RunWait) 3c) Read the msi log file for a successful or failed installation 4) If the computer is not pingable write results to a log file and move on to the next computer in the list 5) Write results to a text file 6) Move onto the next computer in the list How can I make this faster so the script does not have to wait for the file copy and installation to finish in order to move to the next computer in the list. Should I create a sub process for every computer that is online to handle the file copy, installation and log file write? expandcollapse popup#RequireAdmin #include <FileConstants.au3> #include <GUIConstantsEx.au3> ;NOTE: ;!!You need to provide your user name and password on line 39 for this script to work!! Global $ComputerList = @ScriptDir & "\ComputerNames.txt", $ComputerName = FileReadToArray($ComputerList), $LogFile = @ScriptDir & "\Logs\Remote_11.6_Install_" & @MON & "_" & @MDAY & "_" & @YEAR & ".txt", $LogFile2 = @ScriptDir & "\Logs\11.6InstallCommaDelim_" & @MON & "_" & @MDAY & "_" & @YEAR & ".txt" Install() Func Install() FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Remote Installation Started") FileWriteLine($LogFile, @CRLF) For $i = 0 To UBound($ComputerName) - 1 Ping($ComputerName[$i]) If @error Then FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " " & $ComputerName[$i] & " is offline") FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile2, $ComputerName[$i] & "," & "offline") ContinueLoop EndIf FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Starting on: " & $ComputerName[$i]) FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Copying files") FileCopy(@ScriptDir & "\FilesToCopy\*.*", "\\" & $ComputerName[$i] & "\C$\Temp\Agent11.6\", 9) FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Done") FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Running installer") RunWait(@ScriptDir & '\paexec.exe ' & "\\" & $ComputerName[$i] & " -u USERNAME -p PASSWORD -s C:\temp\agent11.6\install_agent.bat", "", @SW_HIDE) ;<-- !!PLEASE PROVIDE YOUR USERNAME AND PASSWORD HERE!! $hFileOpen = ("\\" & $ComputerName[$i] & "\C$\temp\agent11.6\installagent.log") If @error Then FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Unable to open log file, please manually review it.") FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile2, $ComputerName[$i] & "," & "failed") ContinueLoop EndIf $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) If StringInStr($sFileRead, "-- Installation operation completed successfully.") Then FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Installed successfully.") FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Ending on: " & $ComputerName[$i]) FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile2, $ComputerName[$i] & "," & "installed") ElseIf StringInStr($sFileRead, "-- Configuration completed successfully.") Then FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Configuration completed successfully.") FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Ending on: " & $ComputerName[$i]) FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile2, $ComputerName[$i] & "," & "installed") Else FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Installation failed.") FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Ending on: " & $ComputerName[$i]) FileWriteLine($LogFile, @CRLF) FileWriteLine($LogFile2, $ComputerName[$i] & "," & "failed") EndIf Next FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Remote Installation Ended") Exit EndFunc ;==>Install
antmar904 Posted April 18, 2018 Author Posted April 18, 2018 I guess I could copy the installation files and install script to the local computer and let it do everything and from the remote computer write to the log file...
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