Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am assuming you're using the VS2008 built-in installer and not InstallShield or Wise or something like that (which both have much better ways).</p> <p>You can create an installer class that adds it (see below).</p> <p>You then add your installer class as a <a href="http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx" rel="nofollow noreferrer">custom action for install and uninstall</a> and add <a href="http://msdn.microsoft.com/en-us/library/9cdb5eda(VS.71).aspx" rel="nofollow noreferrer">custom actions data</a> with the path you want, for example to add the TARGETDIR to the Path ...</p> <blockquote> <p>/VariableName="Path" /Value="[TARGETDIR]\"</p> </blockquote> <pre><code>using System; using System.ComponentModel; namespace Emv { [RunInstaller(true)] public class Installer : System.Configuration.Install.Installer { public Installer() { } public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); try { var varName = this.Context.Parameters["VariableName"]; var valToAdd = this.Context.Parameters["Value"]; var newVal = String.Empty; var curVal = Environment.GetEnvironmentVariable(varName); if (curVal != null &amp;&amp; curVal.Contains(valToAdd)) { return; } newVal = (curVal == String.Empty) ? valToAdd : curVal + ";" + valToAdd; Environment.SetEnvironmentVariable(varName, newVal, EnvironmentVariableTarget.Machine); } catch (Exception ex) { // message box to show error this.Rollback(stateSaver); } } } } </code></pre> <p>A reference to System.Configuration.Install is required for this code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload