This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Setting the System Path Variable
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 02, 2013
04:30 PM
Setting the System Path Variable
Hi,
I'm trying to add a path to the windows system environment variable:
I'm testing this on a Windows 7 Professional 64-bit with UAC turned off. The code seems to execute without issue when I step through with the debugger but the system path does not get updated...
Am I going about this the wrong way? Does anyone have any ideas about this?
Thanks
I'm trying to add a path to the windows system environment variable:
prototype INT KERNEL32.SetEnvironmentVariable(BYVAL STRING, BYVAL STRING);
function AddPath(svYourPath)
string svPath, , svSubStr, szAppPath;
begin
if (GetEnvVar ( "Path", svPath)==0) then
if !(svPath % svYourPath) then
if (StrSub(svSubStr, svPath, StrLengthChars(svPath) - 1, 1) = 1) then
if (svSubStr = ';') then
svPath = svPath + svYourPath;
else
svPath = svPath + ";" + svYourPath;
endif;
endif;
endif;
if (SetEnvironmentVariable("Path", svPath) = 0) then
MessageBox ("Could not add path to environment!", WARNING);
endif;
else
MessageBox("Error retrieving environment!", WARNING);
endif;
end;
I'm testing this on a Windows 7 Professional 64-bit with UAC turned off. The code seems to execute without issue when I step through with the debugger but the system path does not get updated...
Am I going about this the wrong way? Does anyone have any ideas about this?
Thanks
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 03, 2013
07:56 AM
Look at:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx
SetEvironmentVariable only modifies the current processes copy of the environment variables. The above doc says to persist a change to the registry.
I think at one time I used the code at:
see www.installsite.org > InstallScript Samples > Operating System > Handle PATH Environment on NT.
But that was a while ago and I do not know how it would play on Win 7.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx
SetEvironmentVariable only modifies the current processes copy of the environment variables. The above doc says to persist a change to the registry.
I think at one time I used the code at:
see www.installsite.org > InstallScript Samples > Operating System > Handle PATH Environment on NT.
But that was a while ago and I do not know how it would play on Win 7.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 03, 2013
08:05 AM
Depending on what variant of InstallShield and what project you're using, InstallShield should have a built-in tool to help you set any environment variable. The tool will also take care of your rollback and uninstall actions.
For my own project, I was able to add a directory to the system wide Path variable. For reference, I have the Professional edition and am developing an InstallScript MSI project.
For my own project, I was able to add a directory to the system wide Path variable. For reference, I have the Professional edition and am developing an InstallScript MSI project.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 03, 2013
10:26 AM
jhrlim wrote:
Depending on what variant of InstallShield and what project you're using, InstallShield should have a built-in tool to help you set any environment variable.
I am using Installshield 2012 Spring and this is a Installscript project. I was not able to find anything built into Installshield to set an environment variable... the closest thing I could find was GetEnvVar.
I am going to try setting the path in the registry like phill_mn suggests.
Thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 03, 2013
11:20 AM
A link to this example is at the bottom of the help doc for GetEnvVar
http://kb.flexerasoftware.com/doc/Helpnet/installshield15helplib/GetresEnv_variable_example.htm
http://kb.flexerasoftware.com/doc/Helpnet/installshield15helplib/GetresEnv_variable_example.htm