Thursday, April 26, 2012

Executing VB Scripts within Inno Setup

While InnoSetup comes with its own programming language and you can use COM or build your own DLLs to do custom tasks, one of the easiest and versatile methods that I have come across is to invoke VB Scripts from within the installer. VB Scripts provide a much more richer set of programming constructs, error handling and are much more documented than Pascal Script (Inno Setups own programming language). While VB Scripts dont come close to what can be achieved by C# or C++ program, then can be a very powerful tool given they are around on all windows systems.

Here is an example of how you can invoke VB Scripts from within Inno Setup:

CommandWithParams := ExpandConstant('{app}\validate.vbs') + ' /Ovalidate.out /D'+ ExpandConstant('{app}') + ' /P"' + DBType;

Exec(ExpandConstant('{sys}\cscript.exe'), CommandWithParams, ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ResultCode);

No comments: