0

I am currently working on a program that would run other application under given virtual environment. I am running another application like so:

Process app = new Process();
app.StartInfo.FileName = @"W:\path\to\app\some.exe";
app.EnableRaisingEvents = true;
app.Start();

Now I have faced an issue to change some system variables for application to be run. I have googled for this and could not found the solution. Anybody has any idea how to solve this problem, please help me?
Thanks.

Update

For example I want to set another PATH, JAVA_HOME, AppData variable for child application. Application could be: Google Chrome, Notepad++ or simple .bat script for command line.

iamawebgeek
  • 2,713
  • 1
  • 18
  • 34

1 Answers1

0

assuming you need to change path variable

string pathvariable=Environment.GetEnvironmentVariable("Path");
Environment.SetEnvironmentVariable("Path",pathvariable+";"+"*you new value of path variable*");

if your exe file works fine when you access it directly then you dont need to change the your system variable.. if you change your working directory while accessing the exe file then i guess it will work

amit dayama
  • 3,246
  • 2
  • 17
  • 28
  • Dont you think this would change the systems PATH variable, not the virtual variable for the child application? – iamawebgeek Sep 07 '15 at 05:36