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

Using environment variable in a shortcut

Is it possible to use an environment variable in a shortcut?
What I mean the actual "%VARIABLE%" name.
I have tried #%%ENVVAR% but I get an ICE03 error.

What I want is a shortcut target to look like this:
%ENVVAR%\app.exe (NO harcoded paths!)

This is for applications that point to Microsoft Office\Office10. When we upgrade Office the new path will be Microsoft Office\Office11.

Any ideas?

Thank you
(5) Replies
yes it is possible. But you should use internal MSI Properties rather than external system ones. ie. instead of using %userprofile%(system) use [USERPROFILE]internalMSI.

Also, for the office scenario, just get the property from the Registry (HKLM\Software\Microsoft\Office . . .) via a vbs custom action, and pipe that property over to you shortcut.

Hopethis helps
D
Yes I understand I can use the variables. What I need to to is write the variable.
The target should look like this: %ENVVAR%\app.exe


please look at the attached sample
I see.

Create the shortcut as one that points to a "Pre-Existing file", and set the target to:

"%SYSTEMFOLDER%\Notepad.exe"

You may to play with the quotes.

should work
In Target column of Shortcut table, the format should be as follows.

"[OFFICELOC]word.exe"

Where OFFICELOC property contains %ENVVAR%\. I believe it would behave the way you intended. The backslash is included in the property to conform with MSI directory value convention. The double quotes are needed, since the environment variable, ENVVAR, pointing to location of Office folder is most likely to contain whitespace.
Your sugestion works as well as my solution:
[\%]MSACCESSPATH[\%]\MSACCESS.EXE