[ACCEPTED]-Set InstallPath registry key using Visual Studio Setup project-visual-studio-setup-proje

Accepted answer
Score: 30

Actually, while I was searching for the 3 same thing the following solution was also 2 mentioned:

use [TARGETDIR] in the registry 1 key.

Score: 4

One way to do this would be to create a 10 custom action in your installer. On the 9 custom action you could provide CustomActionData 8 "/Path="[TARGETDIR]*". Within your custom 7 action code you can reference Context.Parameters["Path"] and 6 receive the installation path passed from 5 the installer in your .NET code.

Now that 4 you have the [TARGETDIR] within your custom 3 action code you can continue to use the 2 Microsoft.Win32 namespace to set the registry 1 key.

HTH - Wil

Score: 4

Just to add to putting [TARGETDIR] in the 3 registry key as the value. If you are using 2 the install shield for vs2012 use [INSTALLDIR] instead 1 in the registry key.

Score: 4
  1. follow this steps :
  2. Add a class library project into setup solution.
  3. Add installer file into your class library project.
  4. Add created class library project to your setup application folder
  5. Add created project installer file (On setup custom action window) to "Install" sub tree item.

enter image description here

  1. click on added project and press F4 to open Property window.
  2. on property window set "/pDir="[TARGETDIR]\" into CustomActionData.

enter image description here

  1. on installer file (in class library project) write 2 the follow code to write install path into 1 registry.

     Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        Dim regsrv As New RegistrationServices
        regsrv.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)
        '--------- adding installation directory to stateSaver ----------
        stateSaver.Add("myTargetDir", Context.Parameters("pDir").ToString)
    End Sub
    Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary)
        Dim InstallAddress As String = savedState("myTargetDir").ToString
        Dim regKey As RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software\pourab\Sanjande", True)
        regKey.SetValue("InstalledFolder", InstallAddress)

More Related questions