View Full Version : Alternate Directories based on Setup Type?

01-10-2003, 01:48 PM
Brand new user to IS4, coming from IS2.11...

I would like to create two setup types. One for New Installation, and one for Upgrade Installation. New installations should have a different directory structure than Upgrades (which will use the directory structure already present for older versions).


New Installation
INSTALLDIR = [ProgramFilesFolder]\Company\Product
DATABASEDIR = [CommonAppDataFolder]\Company\Product

Upgrade Installation
INSTALLDIR = [WindowsVolume]\Company\Product

But the default INSTALLDIR and DATABASEDIR entries are only set once in the General section, not on a SetupType basis.

I assume there is something that can be done in VBScript, but I have absolutely no experience with how to do that. Since there is no printed manual, it is also very difficult to find out how to go about doing this.

Any help would be appreciated.


01-10-2003, 03:17 PM
Yes, VBScript will be the way to do this.

Create the normal setup with the following:

INSTALLDIR = [ProgramFilesFolder]\Company\Product
DATABASEDIR = [CommonAppDataFolder]\Company\Product

Sequence the following VBScript after the Setup Types dialog:

Dim SetupType
SetupType = Session.Property("_IsSetupTypeMin")
WindVol = Session.property("WindowsVolume")

if (SetupType="Minimal") then
Session.TargetPath("INSTALLDIR") = WindVol & "\Company\Product"
NewInstDir = Session.TargetPath("INSTALLDIR")
Session.property("DATABASEDIR") = NewInstDir & "\data"
end if

Build and install. At runtime, if you choose "Minimal" setup type, INSTALLDIR and DATABASEDIR will be set to the following:

INSTALLDIR = [WindowsVolume]\Company\Product

Hope that's enough to get you started.

01-10-2003, 03:39 PM
Oops, there is a big problem with that approach. The Setup type dialog comes after after the path dialogs. This won't work at all, since all I want to change is the default values.

01-10-2003, 04:32 PM
While it won't work if the original install was made to a different directory than the old default, this seems to work.

Dim WindVol = Session.property("WindowsVolume")

Dim pFs
Set pFs = CreateObject("Scripting.FileSystemObject")
Dim sDir
sDir = WindVol & "\Company\Product"

if ( pFs.FolderExists( sDir ) ) then
Session.TargetPath("INSTALLDIR") = WindVol & "\Company\Product"
NewInstDir = Session.TargetPath("INSTALLDIR")
Session.property("DATABASEDIR") = NewInstDir & "data"
Session.Property("_IsSetupTypeMin") = "Minimal"
Session.Property("_IsSetupTypeMin") = "Typical"
end if

Next question, can I change the Install Type in this script and hide the dialog?


01-10-2003, 06:09 PM
It's not that simple. We could try with a simple cheat though. Do you have ORCA? If you do:

1. Open your built msi in ORCA
2. Go to ControlEvent Table
3. Assume "Database Folder" dialog is the last one before "Setup Type" dialog. Sort by the first column.
4. Locate entries for DatabaseFolder
5. Locate the Row where "Dialog_" is "DatabaseFolder" and "Control" is "Next". Change that row's "Argument" column from "SetupType" to "ReadyToInstall"
6. Close the msi and save.
7. Run the install

Should skip the "Setup Types" and "Custom Setup" dialogs.

01-10-2003, 06:17 PM
ORCA ? Sounds like the name of a whale!

Anyway, the script I gave above will change the installation type, just not skip the question. The more I think of it, the more I don't want to skip it anyway, just in case someone installed the old version in a non-standard location. These people would need to change the type (as well as the paths, but thats the risk they take when they use nonstandard locations, eh?).

01-10-2003, 06:29 PM
Oh well since it's the weekend here's some food for thought!

ORCA is a really cool tool to have. It comes with the Windows Installer SDK. You can get it from:


You can use a Custom Action to control whether a feature can be installed or not as well. For example:

1. Create a new project
2. Add two root level features and leave default names
3. Add a file to each feature
4. Go to Setup Types and remove both features from all setup types (so they never get installed)
5. Run the following VBScript after Ready to install dialog


=> This will tell the installer to install NewFeature1.

Similarly the following will stop a feature from being installed: