Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > How to modify PATH on a setup projet ?
 

How to modify PATH on a setup projet ?

I need to add the path of an app to the PATH environnement variable when deploying my app. I'm using VS2005 setup projet and I don't know how to do this.

Any idea ?

SBuramoni  Monday, March 17, 2008 4:38 AM

Hi SBuramoni,

You can try to use a custom action to set your installation path to the environment variable. The TARGETDIR property specifies the root destination directory for the installation. You can pass this value to the custom action via its CustomActionData property. As far as I know, there are two options for you to add the environment variable in the custom action.

First one is to use the setx tool to set the environment variable. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\MyFolder to the path, the command would be:

Code Snippet
setx path "%PATH%;C:\MyFolder"

Second one is to add the environment variable to the Registry table. You can add environment variable for current user to the following key:

HKEY_CURRENT_USER\Environment

And system environment variable can be found in the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

For information about custom action, please check:
http://msdn2.microsoft.com/en-us/library/aa368066(VS.85).aspx
http://msdn2.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx

Hope this helps.
Best regards.
Rong-Chun Zhang

Rong-Chun Zhang  Friday, March 21, 2008 3:44 AM

Hi SBuramoni,

You can try to use a custom action to set your installation path to the environment variable. The TARGETDIR property specifies the root destination directory for the installation. You can pass this value to the custom action via its CustomActionData property. As far as I know, there are two options for you to add the environment variable in the custom action.

First one is to use the setx tool to set the environment variable. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\MyFolder to the path, the command would be:

Code Snippet
setx path "%PATH%;C:\MyFolder"

Second one is to add the environment variable to the Registry table. You can add environment variable for current user to the following key:

HKEY_CURRENT_USER\Environment

And system environment variable can be found in the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

For information about custom action, please check:
http://msdn2.microsoft.com/en-us/library/aa368066(VS.85).aspx
http://msdn2.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx

Hope this helps.
Best regards.
Rong-Chun Zhang

Rong-Chun Zhang  Friday, March 21, 2008 3:44 AM
I am trying to use setx as a custom action. But I cannot successfully get the %PATH% variable to work. It does not translate this to the current data in PATH, it just literally places those characters into the path and replaces what was there.

I have tried my arguments ina cmd prompt and it works correctly. The problem only exists when I am trying to enter these arguments in the setx->properties->arguments in the setup project.

Thanks,
Dan Kellett
_LtDan  Thursday, April 30, 2009 11:21 PM
The following link is the best solution to this problem.
Just use Orca to add a value in the Environent table in the MSI.

http://social.msdn.microsoft.com/forums/en-US/winformssetup/thread/1cf9d6f9-6eb9-43f3-8fd0-04397caad800/
_LtDan  Monday, May 04, 2009 7:38 PM

You can use google to search for other answers

Custom Search

More Threads

• How to use VBScript as a Custom Action DLL in .net setup ?
• How to register custom file type
• How do i publish as an offline installer?
• All users folder in VS2003 setup project
• How To Create a SetUP in ASP.NET
• Windows Installer Programs Folder
• Walk-through / FAQ for non-IIS servers
• clickonce deployment downloads frozen
• Sign manifests in code without mage
• Get Application Folder of a winforms application