BillGiles Posted April 12, 2011 Share Posted April 12, 2011 (edited) I've been chewing on this one for a few days making sure each little part works. May not be the most efficient, but it works. If you have suggestions or improvements, feel free to share, I'm always looking for better ways to get this done. I chose to automate the file download and prep work for programs that are updated frequently like Firefox and Videolan. This script also uses a batch file to generate a file list so that the included uninstaller can work properly on the target systems. I use a separate script to manage the actual installation on client systems. The prep script also adjust the main installer script using the version number input by the user of this script. expandcollapse popup;Bill Giles 4/12/2011 $RootPath = ("\\Disk23\SMS_prod\videolan\videolan_") ;save space in long commands $ScriptName = (@ScriptDir & "\vlc_install_master.au3") $UninstallLogFile = (@ScriptDir & "\uninstall.log") $CurVer = InputBox("Videolan Version check", "Enter the numbers of the currently available version, ie: 'X.X.X'. If missing, 7-Zip will also be installed.", "1.1.8") ;Get current version from user. Prefilled with 3.6.12 $ScriptPath = $RootPath & $CurVer $octets = StringSplit($CurVer, ".") ;split version number into octets separated by comma; MsgBox(0,"$Octets",$octets[3]) $OldVer = ($octets[1] & "." & $octets[2] & "." & ($octets[3]) - 1) ;determine oldest directory to be removed, pulls last digit of version number, subtracts one; 1.1.8 becomes 1.1.7 ;##################################################################################################################### Func Install7Zip() RunWait("\\Disk23\SMS_prod\7ZIP\7Zip_4.65\7z465.exe /S") EndFunc ;==>Install7Zip ;##################################################################################################################### Func PrepVideoLanDP() DirRemove($RootPath & $OldVer & "OLD", 1) DirMove($RootPath & $OldVer, $RootPath & $OldVer & "OLD", 1);Rename current version folder if located since we're replacing it; DirCreate($RootPath & $CurVer);make directory for newest version inside \\disk23\sms_prod\videolan\ directory InetGet("http://sourceforge.net/projects/vlc/files/" & $CurVer & "/win32/vlc-" & $CurVer & "-win32.7z/download", "C:\vlc-" & $CurVer & "-win32.7z", 1, 0);Open the link to download current version from interwebz and copy to same folder; Sleep(3000) ;necessary to allow network file operations to complete RunWait('C:\Program Files\7-Zip\7z.exe x C:\vlc-' & $CurVer & '-win32.7z -oC:\');extract the installation files into $RootPath folder MsgBox (0,"Wait", "Files are extracting, wait at least 8 seconds",8) ;wait 8 seconds for 7-zip co finish expanding the files FileCopy(@ScriptDir & "\listgenerator.bat", "C:\vlc-" & $CurVer & "\listgenerator.bat") ;Move the listgenerator.bat file into the script folder FileCopy(@ScriptDir & "\uninstall.exe", "C:\vlc-" & $CurVer & "\uninstall.exe") ;move file into correct location FileChangeDir("C:\vlc-" & $CurVer & "\") ;Set current director so batch file knows where to run RunWait("C:\vlc-" & $CurVer & "\listgenerator.bat") ;generate the file list so the uninstaller will work correctly $StringToRemove = ("C:\vlc-" & $CurVer & "\");Clean up the generated list to remove the path from the filenames $FileToEdit = FileRead($StringToRemove & "\uninstall.log") $FileContents = StringReplace($FileToEdit, $StringToRemove, "", 0, 2) ;replace strings in file FileDelete("C:\vlc-" & $CurVer & "\uninstall.log") ;remove old file FileWrite("C:\vlc-" & $CurVer & "\uninstall.log", $FileContents) ;write new script file $FileContents = StringReplace(FileRead($ScriptName), $OldVer, $CurVer) ;replace strings in file FileDelete($ScriptName) ;remove old file FileWrite($ScriptName, $FileContents) ;write new script file RunWait('"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /in ' & $ScriptName) ;Compile the modified script FileCopy(@ScriptDir & "\vlc_install_master.exe", $RootPath & $CurVer & "\vlc_install_master_" & $CurVer & ".exe") ;move file into correct location FileCopy(@ScriptDir & "\vlc_install_master.au3", $RootPath & $CurVer & "\vlc_install_master_" & $CurVer & ".au3") ;move file into correct location; Sleep(3000) ;necessary to allow network file operations to complete MsgBox (0,"Wait", "Files are Copying, wait at least 10 seconds",10) ;wait 10 seconds for 7-zip co finish expanding the files DirCopy("C:\vlc-" & $CurVer, $RootPath & $CurVer,1) ;move files into correct location FileDelete("C:\vlc-" & $CurVer & "-win32.7z") ;clean up installer that was downloaded EndFunc ;==>PrepVideoLanDP ;##################################################################################################################### ;UpdateVLCInstallScript() ;;Main Script Starts Here; check for installation of 7-Zip before proceeding, it's necessary to decompress source files correctly If FileExists("C:\Program Files\7-Zip\7z.exe") Then ;check for presence of 7-Zip utility, necessary to decompress the files for installation PrepVideoLanDP() ;Call "PrepVideolanDP" Function Else Install7Zip() ;Call "Install7Zip" Function PrepVideoLanDP() ;Call "PrepVideolanDP" Function EndIf Exit ;GO AWAY #cs ################ Contents of "Listgenerator.bat" are just one line: dir /a /b /S /-p /o:gen >uninstall.log ################ #CE Edited April 12, 2011 by BillGiles 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