PDA

View Full Version : Adding scripting logic into Basic MSI project



prash.suresh
04-19-2006, 06:02 AM
Guys,

I am creating a basic MSI project and I am stuck with the following questions. Can anyone help me with this?

1. I want to perform some logic even before my screens come up. Something like OnBegin / Init function sorts. Is it available?

2. Can I interrelate variables between my scripts and those objects(checkbox, radio-buttons etc) in the dialogs?

I have been able to create all the dialogs and suppress a few dialogs based on the options selected in the previous ones. Now I want to insert few lines of code before I pop up another dialog. Million dollar question: Is there a concept of scripting in 'Basic MSI project'?

Please let me know

Thanks
Prashanth

Christopher Painter
04-19-2006, 07:58 AM
You will want to write script cutom actions. For the dialog behavior, control events can be sequenced. For example consider:

Next Button Control Event ( in order of evaluation )
DoAction MyCustomAction 1
NewDialog MyNextDialog Contition: CAALLOWCONTINUE

So lets say MyCustomAction does some logic and sets the public property CAALLOWCONTINUE to 0 ( and displays a MessageBox to the user that there is an error ) or sets it to 1 with no MessageBox.

Basically your CA now controls the control event. Make sense?

BTW if your new into CA's then this is required reading:

http://www.installsite.org/pages/en/isnews/200108/index.htm

prash.suresh
04-20-2006, 06:29 AM
Thanks a lot Chris...

I will start working on this from tomorrow. Please help me if I run into any problems. I will keep them posted.

Thanks
Prashanth

stevepos
04-20-2006, 09:06 AM
I've implemented this to prevent the next dialog being displayed if a property CONTINUE is set to "false". I'm using MSISetProperty() in the Custom Action to set the property and have a CONTINUE<>"false" condition on the NewDialog event.

However, It allows me to continue to the next dialog when the CA has set CONTINUE to "false" but if I then go back to the dialog and click on Next again only then does it prevent me from continuing.

stevepos
04-20-2006, 09:27 AM
My mistake. It does work. Hope it does for you too.

prash.suresh
04-24-2006, 02:18 AM
I have defined custom actions to include VBscripts.

I have say 2 components A and B. I have to install component A when it satisfies a particular condition and B otherwise. How do I control it with scripting?

Also I want to access the registry of the computer to determine a few conditions. Can you please help me with this or guide me to a document that would help me achieving all that I have mentioned above?

Thanks a lot.
Prashanth

wjoconnor
05-01-2006, 02:09 PM
I have defined custom actions to include VBscripts.

I have say 2 components A and B. I have to install component A when it satisfies a particular condition and B otherwise. How do I control it with scripting?

First, you want to create a property which will be used to control which feature/component will be installed. For this example, let's call it "SELECTEDFEATURE" and set its default value to "A". We set the property name to all caps to make it a public feature which gives you some options if you want to run in silent mode.

In the component list or feature list, you go to the Conditions section. By default, the conditions section won't have any entries. Click on the ellipses to bring up the Condition Builder.
For the one you want to install when the property = "A" enter this:
SELECTEDFEATURE = "A"
For the one you want to install when the property isn't "A", enter this:
SELECTEDFEATURE <> "A"

This is evaluated before the component is installed.

To adjust the value of SELECTEDFEATURE, use either the Session.Property("SELECTEDFEATURE") command or the MsiSetProperty(hWnd, "SELECTEDFEATURE", "ValueForSelectedFeature") InstallShield function.

As for checking the registry, I usually use the InstallShield functions because I haven't bothered to memorize the VBScript equivalents. Look up "RegDBGetKeyValueEx Example" in the help file and that will give you all you need to know about reading values from the registry with InstallScript.

Christopher Painter
05-01-2006, 02:19 PM
You may not need a custom action at all. You may be able to use a standard AppSearch ( InstallShield SystemSearch) to populate the property then use the property in a feature or component condition.