2008-08-27

InstallShield Scripting and Commands

About a year ago I had some issues scripting a silent installation for a piece of software we used across the company. It's used by almost every employee and must be updated every time the server is. The problem was the creators of the software did a horrible job programming it and one of their transgressions was using a custom InstallShield setup.

This caused a problem because Windows could not run the install silently. It would just hang and eventually crash because of the custom input the program was requesting. Even though the input was limited to "Next" and "Back" buttons.

This is where the lovely /r argument comes in handy. If you run the command c:\setup.exe /r the setup.exe will launch normally and you can run through the installer. The /r records the installation and creates an ISS file. The ISS file is a record of every action you took during the installation.

Then, you could uninstall the software and run c:\setup.exe /s /f1"c:\my-answer-file.iss" and the software would install silently without any user input.

The ISS file will be saved in the Windows directory as setup.iss, but you can save yourself the trouble by providing a file name and target location with /f1 - c:\setup.exe /r /f1"c:\this-will-be-my-answer-file.iss".

You can take this all one step further and use the /SMS as well. /SMS tells the script, batch file, or whatever you're running to wait until the installation is complete. If you do not use then the installation starts and is flagged as complete almost immediately. If you need to apply a patch or do something with the newly installed program in yourscript you will want to use /SMS like so: c:\setup.exe /s /SMS /f1"c:\my-answer-file.iss".

There are a few other tricks as well. Many times you may just want to extract the files from the setup.exe file and run the bundled .MSI files silently instead. To extract the files you can use the /extract_all. You specify a target folder like this c:\setup.exe /extract_all:"c:\temp".

You may want to delay the installation at times. I can't think of a reason to do this off the top of my head, but it is possible with /delayedstart:X. You replace X with the time in seconds and use it like this c:\setup.exe /delayedstart:10. That command will run setup.exe 10 seconds after I run that command.

Finally, there is a way to uninstall a program as well. You can use /uninst for this. It's not guaranteed to work with every InstallShield executable, but it may be a great shortcut for you one day. You use it just like any of the others c:\setup.exe /uninst.

No comments: