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

Environment Variable Prefix in Shortcut

Hello Everyone:

I'm trying to create shortcuts from within InstallShield. Our software utilizes an environment variable for a number of tasks, and we want to have the shortcuts point to an unexpanded environment variable as the target. So, the installer sets up the custom environment variable (we'll call it %CUSTOM_VAR%), and I'd like the shortcuts in the start menu to point (for example) to:

%CUSTOM_VAR%help\install.html


So, I don't want InstallShield to expand the environment variable. I'd like it to look like the shortcut that's attached.

The problem I seem to be having is that when I go to System Configuration -> Shortcuts and add a new "Shortcut to a preexisting file", I can put in an entry for the target that looks like the following:

[CODE][DIRPROPERTY1][/CODE]

where DIRPROPERTY1 is equivalent to:

%CUSTOM_VAR%help\index.html 


but when I go to install, it makes the shortcut in the start menu as:

C:\%CUSTOM_VAR%help\index.html


How can I remove this prefix so that the shortcuts are added correctly?

Thank you,

~Scott
Labels (1)
0 Kudos
(15) Replies
RobertDickau
Flexera Alumni

Perhaps try pointing to a Property-table property [CUSTOM_VAR] with value %CUSTOMVAR% instead of to a Directory-table property. (A directory entry needs a root, which is presumably why Windows Installer puts C:\ in front.) You'll need to create the property beforehand, and enter it directly in the Shortcut properties instead of browsing, of course.
0 Kudos
jaywire
Level 3

Ok, thanks for that insight, Robert. What is the difference between the Directory table properties and the Property table properties? When I try to put in an absolute path, it creates a variable in what I think of as the property table. So, for example, if I enter into the target field:

Directory1\File2.txt


It actually creates a property, called [DIRPROPERTY2], and then replaces the target line with this:

[code][DIRPROPERTY2]File2.txt[/code]

I assume there is a difference between the directory table and property table. Could you explain to me how to control which table the property is entered into?

Thank you,

~Scott
0 Kudos
RobertDickau
Flexera Alumni

Easiest is probably to create the property yourself in the Property Manager view; browsing in that target-directory view for the shortcut will (as you've seen) create a Directory-table item.

As for the difference, Directory entries are used for destinations, so they need to follow some rules (always end with a backslash, don't allow certain characters, etc.). Property-table properties are used for essentially free-form text data.
0 Kudos
jaywire
Level 3

I also have a bunch of folders that were added, presumably because I tried to create the icons first and then import them as files a while back, that I can't remove. If I right click on the folder in the shortcuts configuration window, it won't let me remove them. Do you know how to remove these folders? I presume they are attached to a component or something, but I'm not sure how to determine which component they are attached to so that I can remove them.

Thanks,

~Scott
0 Kudos
RobertDickau
Flexera Alumni

If you look in the Files and Folders view, there should be a setting to display components, which should help you piece things together.

For another option, perhaps you can open the Direct Editor view and search for components, directories, etc.
0 Kudos
jaywire
Level 3

Ah ok. Thanks, I was able to remove the shortcut folders. I'm still having troubles with the C:\ being prepended, though. I tried adding the property using the property editor, so my property looks like:

CUSTOM_VAR : %CUSTOM_VAR%

And the shortcut looks like:

TARGET: [CUSTOM_VAR]

And it complains when I enter it in manually and click out of the target field that "Field 'Target' of table 'Shortcut': An invalid shortcut target name was supplied."

It doesn't revert the Target field, though. It still looks like [ONLINE_HELP_SHORTCUT]. The install still makes it C:\%CUSTOM_VAR% however, which isn't what I want.

I appreciate your help on this.

Any other ideas?
0 Kudos
RobertDickau
Flexera Alumni

Perhaps open the Direct Editor view and make sure you don't still have a CUSTOM_VAR entry in the Directory table (that is, that it's only in the Property table)?
0 Kudos
jaywire
Level 3

I have a CUSTOM_VAR entry only in the property table. However, there is a directory entry for CUSTOM_VAR_FOLDER, which is the folder into which the shortcut is to be placed on the start menu.

I'm also getting an error when running the installer at this point, on the destination machine. It says:

{{{ Warning 1909: Could not create shortcut Help.lnk. Verify that the destination folder exists and that you can access it. }}}
0 Kudos
RobertDickau
Flexera Alumni

Backing up a bit, does this work in a separate new project?
[LIST=1]
  • In the Property Manager view, create a property ENVVAR with value %TEMP%
  • In a component's Shortcuts editor, create a "shortcut to existing file", typing in any name you want for the target, when prompted
  • Change the shortcut's display name to "Env Var Test"
  • Change the shortcut's Target to [ENVVAR] by typing it in, not browsing
  • Build and run the project, after which you should have a shortcut that opens the Temp folder
  • 0 Kudos
    jaywire
    Level 3

    Ok, so it works in the test project, but not in the more complicated project I have been given to work on. It seems to always append the C:\ to the front.

    ~Scott
    0 Kudos
    RobertDickau
    Flexera Alumni

    Does it work in that project if you create a new property and new shortcut?
    0 Kudos
    jaywire
    Level 3

    No, even if I create a new property, it always seems to append C:\ to the front of the path.
    0 Kudos
    RobertDickau
    Flexera Alumni

    If you create an MSI log file and search for the property name, is there a hint why it changes? If you export the shortcut's component from the project that works into the larger project, does anything change?
    0 Kudos
    jaywire
    Level 3

    Sorry for the long delay, I didn't have a chance to respond. If I export the component from the project that works with the shortcut to the temp folder, it doesn't import the property into the property table that contains the %TEMP% environment variable. Upon building and installing, it doesn't install this newly imported shortcut.

    I'm not sure how to create an MSI log file. We have a log file that we write to, which is arbitrarily placed on the C:\ drive, but it doesn't contain anything related to the stuff InstallShield does automatically (basically, it only contains text that's explicitly written to the log file via UpdateLog calls).
    0 Kudos
    RobertDickau
    Flexera Alumni

    InstallShield has some tools that will help (creating and analyzing MSI log files) under the Tools menu; please look up "log" and "logging" in the help library index for some other options.
    0 Kudos