View Full Version : HOWDOI: Check Install/Uninstall/Features in Custom Action (VBScript)

11-09-2001, 10:03 PM
One of the "Features" in my Setup is a service. I have included an EXE in my installation package that installs/uninstalls the service with the Windows Service Control Manager.


• I want two write a VBScript Custom Action.
• I want to check to see if I am currently Finishing up an Installtion or Uninstalltion.
• I want to Check to see if my "Feature" was in fact installed.
• I want to execute a command line that registers/unregisters my service.


If Session.<MethodToSeeIfMyFeatureWasInstalled> Then
Set sh = CreateObject("WScript.Shell")
If Session.<MethodToDetermineInstallOrUninstall> = "Install" Then
sh.Exec "[INSTALLDIR]\RegSvc.exe /I"
sh.Exec "[INSTALLDIR]\RegSvc.exe /U"
End If
Set sh = Nothing
End If

I would appreciate any help :( --> :D

11-09-2001, 10:19 PM
Ummm Geezzz :eek:

I guess I could create two scripts ?!?!

Execute = During UnInstallaion

Execute = During Installaion

But I still need to decide if my Feature was installed.

11-12-2001, 09:25 AM
If you want to run the Custom Action during install and uninstall, you will have to run two scripts (or the same script twice). As for checking whether the feature was installed, you should be able to do so by looking at the Feature state. Launch the Msi Help (from the Help menu in Express) and from the Index select "Session Object". This has a few topics such as FeatureCurrentState and FeatureRequestState. You might be able to check whether a feature is installed by checking these after the Setup Type dialog.

11-13-2001, 02:31 PM
I found the information you mentioned in the MSI Help file.


*****Session object
*****Required string name of the requested feature, and a primary key into the Feature table.

I have tried the following but all return an error.

MsgBox Session.FeatureCurrentState("My Feature")
If Session.FeatureCurrentState("My Feature") = 3 Then

The error is "FeatureCurrentState,Feature"

MsgBox Session.FeatureCurrentState(1)
If Session.FeatureCurrentState(1) = 3 Then

The error is "Type mismatch: Session.FeatureCurrentState"

The EvaluateCondition method seems like it may have a way of testing to see the state of my feature, but I can't get it to work either.

If you know of a way to test the state of the feature (Installed, etc) .... A CODE SAMPLE WOULD BE NICE.


11-14-2001, 11:29 AM
You have to pass in the Feature Key for the msi to recognize which feature you're talking about. The Feature Key is the Primary Key in the Feature Table. Express generates these keys internally. You will have to open the msi using a tool like ORCA (Comes with the Windows Installer SDK) to find figure out the key of the Feature you want.

To make sure this works you ca try it out on the "Always Install" feature. By default the feature key of this is set to "AlwaysInstall" (Other features usually have key names like F1214).

MsgBox Session.FeatureCurrentState("AlwaysInstall")


MsgBox Session.FeatureCurrentState(AlwaysInstall)

03-13-2006, 02:33 AM
Also, please check if your IS version support spaces in feature names. I am working in IS10.5 and it doesn't allow features like ("My Feature"), instead, it accepts ("MyFeature").

In addition, if ("MyFeature") doesn't exists in feature table, it would give u an error.