-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix installer, add environment variable to installer
- Loading branch information
Showing
5 changed files
with
216 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace VDesk { | ||
[RunInstaller(true)] | ||
public partial class Installer : System.Configuration.Install.Installer { | ||
public Installer() { | ||
InitializeComponent(); | ||
} | ||
|
||
public override void Install(IDictionary stateSaver) { | ||
base.Install(stateSaver); | ||
|
||
string targetDir = Context.Parameters["TARGETDIR"]; | ||
PathAdd(targetDir); | ||
} | ||
|
||
public override void Rollback(IDictionary savedState) { | ||
base.Rollback(savedState); | ||
|
||
string targetDir = Context.Parameters["TARGETDIR"]; | ||
PathRemove(targetDir); | ||
} | ||
|
||
public override void Uninstall(IDictionary savedState) { | ||
base.Uninstall(savedState); | ||
|
||
string targetDir = Context.Parameters["TARGETDIR"]; | ||
PathRemove(targetDir); | ||
} | ||
|
||
|
||
public void PathAdd(string directory) { | ||
directory = directory.TrimEnd('\\'); | ||
|
||
List<string> path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine).Split(';').ToList(); | ||
path.Add(directory); | ||
|
||
string pathStr = string.Join(";", path); | ||
Environment.SetEnvironmentVariable("PATH", pathStr, EnvironmentVariableTarget.Machine); | ||
} | ||
|
||
public void PathRemove(string directory) { | ||
directory = directory.TrimEnd('\\'); | ||
|
||
List<string> path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine).Split(';').ToList(); | ||
path.Remove(directory); | ||
|
||
string pathStr = string.Join(";", path); | ||
Environment.SetEnvironmentVariable("PATH", pathStr, EnvironmentVariableTarget.Machine); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters