Monday, October 25, 2010

Automated Install via Batch file

Below I have designed batch files for installing and uninstalling builds, the important features are the ability to run this unattended and the ability to log any issues that happen during the install.

Install.bat is a simple batch file to do a quite (/qb) install (/i) asynchronously logging all information with verbose output (/L*v). The log file will be the same name as the installer with the (Install.log) extention
Install.bat
IF EXIST %1 msiexec.exe /i %1 /qb /L*v %1.Install.log
EXIT

InstallAll.bat calls Install.bat for each MSIin the build, To make th calls synchronously (START /B /WAIT) it's import to make these calls synchronously if your installing multiple MSI's because msiexec.exe will block all subsequent calls while the first install is running.
InstallAll.bat
START /B /WAIT Install.bat MyProgramOneSetup.msi
START /B /WAIT Install.bat MyProgramTwoSetup.msi
START /B /WAIT Install.bat MyProgramThreeSetup.msi

UnInstall.bat is a simple batch file to do a quite (/qb) uninstall (/X) asynchronously logging all information with verbose output (/L*v). The log file will be the same name as the installer with the (UnInstall.log) extention
UnInstall.bat
IF EXIST %1 msiexec.exe /X %1 /qb /L*v %1.UnInstall.log
EXIT

UnInstallAll.bat calls UnInstall.bat for each MSIin the build, its good to have a way to uninstall if you don't have the option to use a virtualization platform with a snapshotting capabilities.
UnInstallAll.bat
START /B /WAIT UnInstall.bat MyProgramOneSetup.msi
START /B /WAIT UnInstall.bat MyProgramTwoSetup.msi
START /B /WAIT UnInstall.bat MyProgramThreeSetup.msi

WiX: A Developer's Guide to Windows Installer XML

No comments: