Is it possible to register environment variables in Setup Wizard project?

I am creating a Visual Studio 2008 Setup Wizard for my program I see that it is possible to add registry entries, etc.. Is there a possibility to register windows environment variable without writing a custom action? And if I must write a custom action, what is the least painful way to do so?


Using Visual Studio 2008, you can easily do it by setting the appropriate variable in the Windows registry:

  1. In the Solution Explorer, right-click on your project (not solution), and select View->Registry
  2. Create the registry key(folder):
    1. For a User variable: Right-click on HKEY_CURRENT_USER, select "New Key", and name it "Environment".
    2. For a System variable: Right-Click on HKEY_LOCAL_MACHINE, select "New Key", and name it "SYSTEM". Continue doing this to create the path "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" .
  3. Right-click on the Environment key(folder), select New->String, and give it the name you want.
  4. With the string selected, find the Properties window (Alt+Enter will bring it up)
  5. In the Properties window, fill in the Value you want.

If you want the Value to reference the installation directory, you can do it like this using property variables: [TARGETDIR]SomeFile.ext (see for more property variables)

Windows Installer does support environment variables through Environment table, but Visual Studio setup projects do not allow you to use it.

A solution is to use a different setup authoring tool which supports environment variables:

Another solution is to manually add it in Environment table by editing the MSI with Orca.

There's also the custom action approach you mentioned.

Need Your Help

x86 MUL Instruction from VS 2008/2010

c++ visual-studio compiler-construction assembly x86

Will modern (2008/2010) incantations of Visual Studio or Visual C++ Express produce x86 MUL instructions (unsigned multiply) in the compiled code? I cannot seem to find or contrive an example wher...

Creating read-only exchange tasks for a user

exchange-server task readonly exchangewebservices exchange-server-2010

I want to use the Exchange Web Services in a service (more specifically in a sharepoint activity) in order to assign a task to someone else.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.