KP

Custom action based on VB Script result

Hello -- I am evaluating your tool for purchase. Almost all our requirements are met, except for this one:

I have a VB Script that will be executed during the installation process. It is to validate a few items to ensure that the work station that the product is being installed on is *valid* (to meet some of our proprietary standards).

So, the VBScript, when executed, will return FAIL if checks fail. If the value is FAIL (or non-zero), we want the installer to stop processing the install with a message 'You will not be able to install this software Please contact..' etc.

Can this be accomplished? This is a show stopper.

Thanks for your help in advance.

Best,
KP
ps: We have tried the custom action property of "Synchronous Action check return code", but that doesnt seem to work
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

Yes, this is doable.

But I think that returning an error value from a VBScript function is a little tricky, please check the MSDN.

Cata
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
KP

Cata -- Appreciate the quick response. You said that my problem can be solved? Can you tell us how ?

Best
KP
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

Our VBScript guy is away, he'll post the code on Monday.
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dorel
Posts: 25
Joined: Mon Oct 18, 2004 8:13 am

Hello,
A custom action of type VBScript can return a value that tell the installer to stop the installation.
A link to MSDN where this is explained: http://msdn.microsoft.com/library/defau ... ctions.asp
However the installation will stop with an error message shown by Windows Installer and not by you.
I recommend the following solution - possible only if the file containing the VBScript is not installed by the package-:
Make your custom action return true always BUT:
1-schedule it after StartServices standard action and make it an immediate custom action.
2.Instead of returning FAILURE your custom action should set a property with some value e.g

Code: Select all

Session.Property("MY_ERROR") = "ERROR"
3.Create a custom action of type "Error Message" right after this custom actiom and set the condition of this custom action to "(NOT Installed) AND MY_ERROR"-supposing that the VBScript custom actiom had the condition "NOT Installed". In the Message Text field of this custom action enter the text you want to be displayed to the user if your requirements are not met. This solution is IMHO much user friendly then the first solution.
Let me know if you have any other questions.
Dorel Pislan
Advanced Installer Team
http://www.advancedinstaller.com
Guest

Hi Dorel,
The 'Error Message' option under custom actions is disabled. How do I enable it to try your solution #3? Thanks.
Janaki
UdreaMihai
Posts: 90
Joined: Wed Mar 23, 2005 8:13 am

Hello,

As Dorel said, in order to enable "Error Message" you must add StartServices to the tree by using the Show Standard Action command from the popup menu or from the toolbar. Just go to the Show Standard Action toolbar button > Before Finalization > StartServices. Then "Error Message" will be enabled.

Best,

Mihai
Udrea Mihai
Advanced Installer Team
http://www.advancedinstaller.com
Janakis

Hi Dorrel & Udrea!
Sorry to come back on this after such a long time. But Iam running into problems when I try the solution you had suggested.

My VBScript gets executed until setting a property called "ERROR_STATUS" based on validation conditions. After that I get the following error :

"There is a problem with Windows Installer Package. A script required for this install to be complete could not be run. Contact your support personnel or package vendor".

Within my aip, this is what I have :
Custom Actions : Start Services -> err_msg.vbs => I just display error message based value of property ERROR_STATUS which I set in my custom action VBScript.

Custom Action : Install ->validate_machine.vbs => I have some validation code.

I have the property ERROR_STATUS defined in Install Parameters to be FALSE initially.

Any help will be most appreciated.

Rgds
Janaki
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Your problem might be caused by the fact that the script must always return "1" after the value of the property has been set properly.
This way Windows Installer does not stop the installation with it's own error message.

All custom actions must have immediate execution.

Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”