Search code examples
c#windows-installer

How to modify the environment path for the setup project in visual studio


I have a setup project in Visual Studio 2010 that I use to create an installation kit (MSI). I need to update the environment path to add an entry when the MSI is installed. Any idea how to do that?

I can't find the option that let me access the environment. Only thing I see that might do is to directly edit the registry. Anything better I can do, or that is my only option?

Thanks Tony


Solution

  • Visual Studio setup projects cannot set environment variables. However, you can try using a custom action. Here is some sample VBScript code:

    Set WshShell = CreateObject("WScript.Shell") 
    Set WshEnv = WshShell.Environment("SYSTEM") 
    WshEnv("Path") = WshEnv("Path") & ";myPath"
    

    You can copy it in a .VBS file and add that file as an install custom action.