/build/static/layout/Breadcrumb_cap_w.png

How do I define folder names at install-time?

Greetings!

If I have a user provide text, which, in this case, I put into a property called WorkstationNumber, how do I then USE that text to define the name of a folder into which I need to put files?

Example:

User enters "003" and then I need to create a folder under C:\Program Files\MyApp\WorkstationData\USERENTRYHERE.

I've tried using a property [WorkstationNumber] in the Directories table, but, as expected, it wants a static string.

Help, please! How would I do this?

Thanks in advance,

- Sean

0 Comments   [ + ] Show comments

Answers (5)

Posted by: MSIMaker 20 years ago
2nd Degree Black Belt
0
If you want to get a workstation name and insert it into msi then you can use the built in variable [ComputerName]

If you make a folder called C:\Program Files\[%ComputerName] then the msi will automatically get the local computer name and insert it in its place. This works for ODBC settings and ini files as well.
Posted by: Robo Scripter 20 years ago
Orange Senior Belt
0
Sean,

From the Windows Installer SDK Help file;

**********************************************************************

Custom Action Type 35
This custom action sets the install directory from a formatted text string. For more information, see How do I change the target location for a directory?

Source
The Source field of the CustomAction table contains a key to the Directory table. The designated directory is set by the formatted string in the Target field using MsiSetTargetPath. This sets the target path and associated property to the expanded value of the formatted text string in the Target field. Do not attempt to change the location of a target directory during a Maintenance Installation. Do not attempt to change the target directory path if some components using that path are already installed for the current user or for a different user.

Type Value
Include the following value in the Type column of the CustomAction table to specify the basic numeric type.

Constants Hexadecimal Decimal
msidbCustomActionTypeTextData + msidbCustomActionTypeDirectory 0x023 35


Target
The Target column of the CustomAction table contains a text string formatted using the functionality specified in MsiFormatRecord (without the numeric field specifiers). Parameters to be replaced are enclosed in square brackets, […], and may be properties, environment variables (% prefix), file paths (# prefix), or component directory paths ($ prefix). Note that directory paths always end with a directory separator.

Return Processing Options
Not used.

Execution Scheduling Options
Include optional flag bits in the Type column of the CustomAction table to specify execution scheduling options. These options control the multiple execution of custom actions. For a description of the options, see Custom Action Execution Scheduling Options.

In-Script Execution Options
Not used.

Return Values
See Custom Action Return Values.

Remarks
If you set a private property in the UI sequence by authoring a custom action in one of the user interface sequence tables, that property is not set in the execution sequence. To set the property in the execution sequence you must also put a custom action in an execution sequence table. Alternatively, you can make the property a public property and include it in the SecureCustomProperties property.

See Also
Custom Action Reference, About Custom Actions, Formatted Text Custom Actions, Using Custom Actions, Custom Action Return Values
**********************************************************************
I have a few installations that have dynamic folders that use this action. I works quite well, but take care as placement of the action in the correct sequence is critical.

Regards,
Posted by: sean_c_roberts 20 years ago
Senior Purple Belt
0
Wow!

Thank you both for the excellent replies!

Might you (both) suggest a place (probably in the SDK) which explains all the variable/property formatting conventions?

For example, I'm not sure what the single "%" means in a property.

Would using [%UserInput] as a directory name allow me to install files to this directory?

Thanks in advance,

- Sean
Posted by: Robo Scripter 20 years ago
Orange Senior Belt
0
Sean,

Again from the Windows Installer SDK;

********************************************************
Platform SDK: Windows Installer
Formatted
The Formatted data type is a text string that is processed to resolve embedded property names, table keys, environment variable references, and other special substrings. The following conventions are recognized to resolve the string:

Square brackets ([ ]) or curly braces ({ }) with no matching pair are left in the text.
If a substring of the form [propertyname] is encountered, it is replaced by the value of the property. If propertyname is not a valid property, then the substring is left unchanged.
The square brackets may be iterated and the property names are resolved from inside out. For example, suppose the substring [[PropertyA]] appears in the text. First, the value of property PropertyA is retrieved. If the value is a valid property name, such as PropertyB, then the value of PropertyB is retrieved, and the entire substring [[PropertyA]] is substituted with the value of PropertyB. If PropertyA is not a valid property name, or if the value of PropertyA is not a valid property name, then the substring is blank.

Etc...

********************************************************
It is a long subject, just type in “Formatted" in the SDK Search engine.

You will find that this topic page is one of the best to help you understand formatted values in the installer. The [%Something] is how the installer retrieve a System Environment Variable Value.

You would also be well advised to remember the differences between public and private properties.

Regards,
Posted by: sean_c_roberts 20 years ago
Senior Purple Belt
0
Awesome!

Thanks!

I DID dig through the SDK for a while, but I never did find the info I needed...

The info I'm getting now after having looked up FORMATTED as a type is EXCELLENT and exactly what I needed.

Respectfully,

- Sean Roberts
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ