Passing a command line to Command Window from Visual Studio app

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
Even though this is a Windows Form, I feel this question belongs here, if I am wrong - my apologies!
I am writing an app to use a Windows Form to modify a .config file related to IIS Express. No matter how I attempt to pass a command line to the Command Window, I cannot get it to pass. The window opens to the Visual Studio debug directory and stays there, and my CD command does not generated or shown. Basically all I am trying to do is run a CD command to get to the IIS Express directory, then I will run the APPCMD command with the appropriate switches. Thank you for any help!
Relevent code: string strCmdText;
strCmdText = ShellCommand.ToString();
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = @"C:WindowsSysWOW64cmd.exe";
startInfo.Arguments = @"/C /cd c:program files (x86)IIS Express";
//startInfo.Arguments = "/C " + strCmdText;
process.StartInfo = startInfo;
//Process.Start();
Process.Start("CMD.exe", @"cd c:program files (x86)IIS Express");

View the full article
 
Back
Top