jidjan
Posts: 7
Joined: Thu Jul 24, 2008 7:54 pm

Lunch Condition

I am currently evaluating advanced installer and new to MSI. My project seems to be working except with the a batch file as my second lucnh condition. The batch file generate a return code 0 for success, 10 for wait, and abort if greater than 10. How can I do this?

Thanks,
jidjan
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Lunch Condition

Hello jidjan,

you can probably implement this in a custom action in VBScript or JScript:

Code: Select all

var shell = new ActiveXObject("WScript.Shell");
shell.Popup(shell.Run("cmd.exe /c exit 1", 1, true));
With best regards

Clemens Anhuth
jidjan
Posts: 7
Joined: Thu Jul 24, 2008 7:54 pm

Re: Lunch Condition

canhuth wrote:Hello jidjan,

you can probably implement this in a custom action in VBScript or JScript:

Code: Select all

var shell = new ActiveXObject("WScript.Shell");
shell.Popup(shell.Run("cmd.exe /c exit 1", 1, true));
With best regards

Clemens Anhuth
Hi Clemens,

I am not really good on scripting, can please elaborate? Really appreciate your help.

Thanks,
Jidjan
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Lunch Condition

Hello jidjan,

as I understand it Advanced Installer utilizes the Windows Installer technology, which in turn - as I understand it - does not offer a specific mechanism for your purpose.

If that is so, you may need to implement the logic to call and deal with the result of the batch file yourself, either in form of custom code in a DLL or in form of a script written in JScript or VBSript. You can call your code in a custom action in various stages of the installation.

So at the point where you want to call and deal with the result of the batch file you could add a custom action that calls your script code to perform the necessary steps.

The following code create a new WScript.Shell object. We need that to execute files/batch scripts via its Run() method/function. Also we use its Popup() method to show a popup with our message:

Code: Select all

var shell = new ActiveXObject("WScript.Shell");
var commandToExecute = "cmd.exe /c exit 1";
var result = shell.Run(commandToExecute, 1, true);
shell.Popup("Result/Exit code of command: " + result);
If you put this code into a file "something.js" you can execute it via doubleclick on Windows. You can keep writing and testing the code like this until it is ready for testing inside the installer, this may be more efficient than creating and running the installer after every change in the script file.

I have found that writing custom actions for Windows Installer is an error prone and frustrating task for several reasons, and because of this writing them should be done by an application developer at least.



With best regards

Clemens Anhuth

Return to “Common Problems”