Tuesday, February 20, 2018

Inno Setup, Part 9. Compiling installer from command line.

Sometimes you may need to compile your Inno Setup installer (*.iss file) from command line, script or another application. Basically this is done with the help of ISCC.exe which is being installed together with Inno Setup:

iscc "c:\My scripts\my script.iss"

Note double quotes, they are necessary in case path contains any whitespaces. Also you may need to specify path to iscc itself. Now let's describe how you can do the same thing from C# application.

   Process process = new Process();
   ProcessStartInfo startInfo = new ProcessStartInfo();
   startInfo.WindowStyle = ProcessWindowStyle.Hidden;
   startInfo.FileName = "cmd.exe";
   string compiler = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe";
   string outputName = "output";
   string installer = @"D:\MyInstallerIsHere.iss";
   startInfo.FileName = "\"" + compiler + "\"";
   startInfo.Arguments = " /Q " + "\""+ installer+ "\"" + " /F" + "\""+outputName + "\"";
   process.StartInfo = startInfo;

ProcessWindowStyle.Hidden will for Process will help us to hide console window. What we are doing here is launching again ISCC.exe with iss script name as main argument. Other arguments are: /Q for quiet compilation, /F - for overriding output installer name (you can skip this if default name is OK for your purposes).

No comments:

Post a Comment