adeel_aziz
Flexera beginner

How to use %ALLUSERSPROFILE% environment variable in InstallScipt

Hi

I have an install script in which I want to open a file located at %ALLUSERSPROFILE%\MyFolder

So I used this code:

set oDoc = CreateObject("Microsoft.XMLDOM");
.
.
.
if (oDoc.load("[ALLUSERSPROFILE]\\MyFolder\\TestFile.xml")) then
.
.
.

But this is not working. Although I have created the folder %ALLUSERSPROFILE%\MyFolder in Application Data > Files and Folders and that folder creates successfully. I also copy the file TestFile.xml over there and it also shows up after the install. But when the code does not seem to have any effect in the file since I am trying to open it and edit it in %ALLUSERSPROFILE%\MyFolder. I have tried by copying this file in the INSTALLDIR location and open and edit there and that works fine so there does not seem to be a problem with my code.

I think I am using the wrong variable in the path which is [ALLUSERSPROFILE].

Can anyone tell me how to I access the %ALLUSERSPROFILE% location in the install script.

Many Thanks,

Adeel.
Labels (1)
0 Kudos
1 Reply
ch_eng
Flexera beginner

Re: How to use %ALLUSERSPROFILE% environment variable in InstallScipt

Adeel,

If you have an InstallScript project, that variable will not work (see the bottom of this link: http://helpnet.installshield.com/installshield18helplib/IConvertScriptToPro.htm at "The following Windows Installer folder specifiers are not supported in InstallScript projects:"). Unfortunately, I don't know what the equivalent variable would be in an InstallScript project - perhaps someone else can help with that.

You may want to add a temporary debug messagebox to see the actual file path you are passing:

[CODE]MessageBox( "[ALLUSERSPROFILE]\\MyFolder\\TestFile.xml", INFORMATION );[/CODE]

Also, you may want to use the newer the newer "MSXML2.DOMDocument.6.0" instead of "Microsoft.XMLDOM".

HTH
0 Kudos