0

I'm trying to launch cmd.exe from my c# code for debugging, but it seems that setting the UseShellExecute set to false does not show the window, which is what I would like here.

I do need to set UseShellExecute==false however to set the environment variables. So is there another way to set the required environment variables and launch the cmd.exe window?

        string ev_path = System.Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
        string ev_java = System.Environment.GetEnvironmentVariable("JAVA_HOME", EnvironmentVariableTarget.Machine);
        string ev_adt = System.Environment.GetEnvironmentVariable("ANDROID_HOME", EnvironmentVariableTarget.Machine);

        ProcessStartInfo _pinfo = new ProcessStartInfo
        {
            WorkingDirectory = home_drive + @"\orderato-android", 
            FileName = "CMD.exe",
            Arguments = "/K ant debug",
            UseShellExecute = false

        };
        _pinfo.EnvironmentVariables["Path"] = ev_path;
        _pinfo.EnvironmentVariables["JAVA_HOME"] = ev_java;
        _pinfo.EnvironmentVariables["ANDROID_HOME"] = ev_adt;


        Process _p =  Process.Start(_pinfo);
        _p.WaitForExit();
Community
  • 1
  • 1
Alia
  • 1
  • 3
  • @CodeCaster - That was a bad close IMHO. The question isn't that well phrased to begin with, but the OP already knew how to set the environment variables. There seems to be some problem with the UseShellExceute flag though – Martin Ba Jan 19 '15 at 14:22
  • 1
    @CodeCaster - oh sorry. Should have checked the history. When you closed the question it was actually a dupe. Now it isn't any more. – Martin Ba Jan 19 '15 at 14:24

1 Answers1

0

Only restart your pc and try again, for some reason that variable only updates internally when you restart your pc.

acamro
  • 1