Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 3

Dynamic installation path


Is it possible to install my software to a folder/path which name is dynamic?
It changes according to a variable defined and stored in a custom dialog textbox.

For example, I want to install to the path "C:\company\software [VARIABLE]".

Thanks in advance.
Labels (1)
0 Kudos
(4) Replies
Technical Writer
Technical Writer

On the dialog where the user is setting the VARIABLE property, you can add an event to update INSTALLDIR

Argument= C:\company\software [VARIABLE] (do not use quotes)
0 Kudos
Level 6

Depending on the project type and your installer design you will need to do different things.
I have the need to have one or many install paths in my installations. Most of these are not changeable by the user but are not known until runtime.
I search for some registry values and set the paths once found. In your case, instead of searching for values, you would set values that the user provides.

In general here is what I do:
I create a new root folder in the folder list. This folder is something logically named and at the same level as INSTALLDIR and all the other predefined locations.
I then add components to static paths below this folder. For example bin or tools. Remember the user is only setting the parent location and not dictating how your files are deployed.
When I know the location at runtime, I set the folder location in one of two ways (depending on project type)

Method 1: Basic MSI: Use a Set Directory CA.
This is usually very strait forward so long as you understand the scheduling involved.
Scheduling is really fancy way of saying "in what order should this action happen relative to all the other actions in the installer".
A sequence is a group of actions that are scheduled to run during different modes of operation of your install. There are 3 modes or sequences, UI, Execution, and Advertise.
I don't do much with advertise so I can't offer any insight there but the default way a user would run your installer is in the UI sequence (double click on setup.exe and go to town)
In this mode you could schedule the set directory action to happen just before you transitioned to the execute sequence.

The Execute sequence should also be considered if you want to support silent installs.
Since a silent install will not display any UI, the UI Sequence is not run at all thus skipping your set directory CA.
You should come up with a default value in these cases so that the install path is meaningful.

Method 2: InstallScript MSI projects
This method is also sorta easy but it is a little less elegant.
Once you know your INSTALLDIR, in the OnFirstUIBefore function, you can call MsiSetTargetPath(ISMSI_HANDLE, "logical name from directory table", PathValueVariable or Literal);

Hope this helps.
0 Kudos
Level 4

I used InstallScript code in a Custom Action. Sequence it before files are installed. Also, I define my LICENSE_DIR as he described above

export function SetLicenseDirectory(HWD);

function SetLicenseDirectory ()
STRING szBase;
szBase = UpdateBaseDirectory(INSTALLDIR);
MsiSetProperty(ISMSI_HANDLE, "LICENSE_DIR", szBase^"License");

* function UpdateBaseDirectory(STRING)
function STRING UpdateBaseDirectory (tgtDir)
STRING baseDir;
NUMBER lastPos;

// first, find out if the last characther in the string
// is a backslash

baseDir = tgtDir;

StrRemoveLastSlash ( baseDir );

pos = StrFindEx(baseDir, "\\", 0);

if (pos < 0) then
return (baseDir);

lastPos = pos;
while (pos >= 0)
pos = StrFindEx(baseDir, "\\", pos + 1);
if pos > 0 then
lastPos = pos;

StrSub(baseDir, baseDir, 0, lastPos);

0 Kudos
Level 2

What do you mean by static and dynamic pages? Im sorry Im quite new to this. All I know is that you should have fresh content on a regular basis on your blogs to have better google ranking.
0 Kudos