dufran3 Posted December 14, 2010 Share Posted December 14, 2010 I am trying to run a silent install of iTunes as a part of an auto install program that I am putting together....I'm not sure how to install it silently efficiently. Here is what I have so far. expandcollapse popupFunc _InstalliTunes($flag) Local $Sourcecheck = FileExists($InstallSource & $QuickTimeFileName) Local $Destcheck = FileExists($TempFolder & $QuickTimeFileName) Local $Sourcecheck2 = FileExists($InstallSource & $iTunesFileName) Local $Destcheck2 = FileExists($TempFolder & $iTunesFileName) Local $Sourcecheck3 = FileExists($InstallSource & $AppleAppSupportFileName) Local $Destcheck3 = FileExists($TempFolder & $AppleAppSupportFileName) Local $Sourcecheck4 = FileExists($InstallSource & $MobileDeviceFileName) Local $Destcheck4 = FileExists($TempFolder & $MobileDeviceFileName) Local $Sourcecheck5 = FileExists($InstallSource & $SoftwareUpdateFileName) Local $Destcheck5 = FileExists($TempFolder & $SoftwareUpdateFileName) Local $Sourcecheck6 = FileExists($InstallSource & $BonjourFileName) Local $Destcheck6 = FileExists($TempFolder & $BonjourFileName) Local $Sourcecheck7 = FileExists($InstallSource & $MobileMeFileName) Local $Destcheck7 = FileExists($TempFolder & $MobileMeFileName) Select Case $Sourcecheck == 1 And $Destcheck == 0 FileCopy($InstallSource & $QuickTimeFileName, $TempFolder, 1) Case $Sourcecheck == 1 And $Destcheck == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck == 0 And $Destcheck == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck == 0 And $Destcheck == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck == 1 Then RunWait($TempFolder & $QuickTimeFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck2 == 1 And $Destcheck2 == 0 FileCopy($InstallSource & $iTunesFileName, $TempFolder, 1) Case $Sourcecheck2 == 1 And $Destcheck2 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck2 == 0 And $Destcheck2 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck2 == 0 And $Destcheck2 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck2 == 1 Then RunWait($TempFolder & $iTunesFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck3 == 1 And $Destcheck3 == 0 FileCopy($InstallSource & $AppleAppSupportFileName, $TempFolder, 1) Case $Sourcecheck3 == 1 And $Destcheck3 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck3 == 0 And $Destcheck3 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck3 == 0 And $Destcheck3 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck3 == 1 Then RunWait($TempFolder & $AppleAppSupportFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck4 == 1 And $Destcheck4 == 0 FileCopy($InstallSource & $MobileDeviceFileName, $TempFolder, 1) Case $Sourcecheck4 == 1 And $Destcheck4 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck4 == 0 And $Destcheck4 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck4 == 0 And $Destcheck4 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck4 == 1 Then RunWait($TempFolder & $MobileDeviceFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck5 == 1 And $Destcheck5 == 0 FileCopy($InstallSource & $SoftwareUpdateFileName, $TempFolder, 1) Case $Sourcecheck5 == 1 And $Destcheck5 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck5 == 0 And $Destcheck5 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck5 == 0 And $Destcheck5 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck5 == 1 Then RunWait($TempFolder & $SoftwareUpdateFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck6 == 1 And $Destcheck6 == 0 FileCopy($InstallSource & $BonjourFileName, $TempFolder, 1) Case $Sourcecheck6 == 1 And $Destcheck6 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck6 == 0 And $Destcheck6 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck6 == 0 And $Destcheck6 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck6 == 1 Then RunWait($TempFolder & $BonjourFileName & ' /passive /norestart') EndIf Select Case $Sourcecheck7 == 1 And $Destcheck7 == 0 FileCopy($InstallSource & $MobileMeFileName, $TempFolder, 1) Case $Sourcecheck7 == 1 And $Destcheck7 == 1 If $Debug == 2 Or 3 Then _WriteLogFile($LogFileOpen, 'The file already exists in the destination') Case $Sourcecheck7 == 0 And $Destcheck7 == 0 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) Case $Sourcecheck7 == 0 And $Destcheck7 == 1 MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource & @CRLF & 'The file already exists in the destination') EndSelect If $Destcheck7 == 1 Then RunWait($TempFolder & $MobileMeFileName & ' /passive /norestart') EndIf EndFunc ;==>_InstalliTunes Link to comment Share on other sites More sharing options...
sleepydvdr Posted December 14, 2010 Share Posted December 14, 2010 Is there any reason why you are doing the checks to see if it already exists? Wouldn't it just upgrade if you ran them silently? I'm downloading iTunes to play with it. I do see something that you will need to change. The "/passive /norestart" switches tell me these are .msi files. You will need to modify your RunWait(s) to look something like this: RunWait("msiexec /i " & $TempFolder & $iTunesFileName & ' /passive /norestart') #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
dufran3 Posted December 14, 2010 Author Share Posted December 14, 2010 Is there any reason why you are doing the checks to see if it already exists? Wouldn't it just upgrade if you ran them silently? I'm downloading iTunes to play with it. I do see something that you will need to change. The "/passive /norestart" switches tell me these are .msi files. You will need to modify your RunWait(s) to look something like this: RunWait("msiexec /i " & $TempFolder & $iTunesFileName & ' /passive /norestart') Thanks, for the help w/ the RunWait. I added the Case, Select sequence because I wanted to log this process, in case of error, so I can check it. Your thinking it is unnecessary? Link to comment Share on other sites More sharing options...
dufran3 Posted December 14, 2010 Author Share Posted December 14, 2010 (edited) Is this better? expandcollapse popupFunc _InstalliTunes($flag) Local $Sourcecheck = FileExists($InstallSource & $QuickTimeFileName) Local $Sourcecheck2 = FileExists($InstallSource & $iTunesFileName) Local $Sourcecheck3 = FileExists($InstallSource & $AppleAppSupportFileName) Local $Sourcecheck4 = FileExists($InstallSource & $MobileDeviceFileName) Local $Sourcecheck5 = FileExists($InstallSource & $SoftwareUpdateFileName) Local $Sourcecheck6 = FileExists($InstallSource & $BonjourFileName) Local $Sourcecheck7 = FileExists($InstallSource & $MobileMeFileName) If $Sourcecheck == 1 Then FileCopy($InstallSource & $QuickTimeFileName, $TempFolder, 1) RunWait($TempFolder & $QuickTimeFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck2 == 1 Then FileCopy($InstallSource & $iTunesFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $iTunesFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck3 == 1 Then FileCopy($InstallSource & $AppleAppSupportFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $AppleAppSupportFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck4 == 1 Then FileCopy($InstallSource & $MobileDeviceFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $MobileDeviceFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck5 == 1 Then FileCopy($InstallSource & $SoftwareUpdateFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $SoftwareUpdateFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck6 == 1 Then FileCopy($InstallSource & $BonjourFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $BonjourFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf If $Sourcecheck7 == 1 Then FileCopy($InstallSource & $MobileMeFileName, $TempFolder, 1) RunWait("msiexec /i " & $TempFolder & $MobileMeFileName & ' /passive /norestart') Else MsgBox(0, 'File not found', 'Source file not found at: ' & $InstallSource) EndIf EndFunc ;==>_InstalliTunes Edited December 14, 2010 by dufran3 Link to comment Share on other sites More sharing options...
sleepydvdr Posted December 16, 2010 Share Posted December 16, 2010 (edited) Your script looks good. As promised, I played around with it and created an installer a little differently than yours. I thought this may give you some ideas in case you want to play with it. The way I came up with is to more efficiently install it. The behavior I noticed is that when you start the install process, the .msi files copy themselves to the temp directory from anywhere you start the installation unless the installation starts in the temp directory. Therefore, I packed the files into the AutoIt executable and extracted them directly to the temp directory. This way, you will not need to do the checks to see if the files are present. I can see the benefit of having an error log, so I added that in. All you need to do is have a blank file called error.log (or whatever you want) in the folder where you compile the script. I also ran the msi files with a /qn switch to get rid of the progress bars and added my own. I think it gives a more unified feel to it rather than 6 separate progress bars. Finally, I made it clean up the temp folder after installing. expandcollapse popup;Copy files to temp folder ProgressOn("iTunes", "Preparing to install") FileInstall("QuickTime.msi", @TempDir & "\QuickTime.msi") ProgressSet(20) FileInstall("AppleApplicationSupport.msi", @TempDir & "\AppleApplicationSupport.msi") ProgressSet(40) FileInstall("iTunes.msi", @TempDir & "\iTunes.msi") ProgressSet(60) FileInstall("AppleMobileDeviceSupport.msi", @TempDir & "\AppleMobileDeviceSupport.msi") ProgressSet(80) FileInstall("AppleSoftwareUpdate.msi", @TempDir & "\AppleSoftwareUpdate.msi") ProgressSet(100) FileInstall("Bonjour.msi", @TempDir & "\Bonjour.msi") ProgressOff() FileInstall ("error.log", @TempDir & "\error.log") ;Install the different programs ProgressOn("iTunes", "Installing") RunWait("msiexec /i" & @TempDir & "\QuickTime.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "Quicktime error code: " & @error) EndIf ProgressSet(20) RunWait("msiexec /i" & @TempDir & "\AppleApplicationSupport.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "Apple Application Support error code: " & @error) EndIf ProgressSet(40) RunWait("msiexec /i" & @TempDir & "\iTunes.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "iTunes error code: " & @error) EndIf ProgressSet(60) RunWait("msiexec /i" & @TempDir & "\AppleMobileDeviceSupport.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "Mobile Device error code: " & @error) EndIf ProgressSet(80) RunWait("msiexec /i" & @TempDir & "\AppleSoftwareUpdate.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "Software Update error code: " & @error) EndIf ProgressSet(100) RunWait("msiexec /i" & @TempDir & "\Bonjour.msi /qn") If @error Then FileWrite(@TempDir & "\error.log", "Bonjour error code: " & @error) EndIf ProgressOff() ;Clean up temp folder FileDelete(@TempDir & "\QuickTime.msi") FileDelete(@TempDir & "\AppleApplicationSupport.msi") FileDelete(@TempDir & "\iTunes.msi") FileDelete(@TempDir & "\AppleMobileDeviceSupport.msi") FileDelete(@TempDir & "\AppleSoftwareUpdate.msi") FileDelete(@TempDir & "\Bonjour.msi") ;Installation is complete MsgBox(0, "Complete", "iTunes has been installed.") Edited December 16, 2010 by sleepydvdr #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
dufran3 Posted December 16, 2010 Author Share Posted December 16, 2010 thx man! 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