2

I need to start a complete command line like "app.exe /arg1:1 /arg2:true" from my C# app.

Process.Start and ProcessStartInfo needs to have the filename and arguments property set. Is there a way to mimic a true shell-like execute (like the one when you press WIN+R)?

Stefan Koell
  • 1,436
  • 3
  • 15
  • 24
  • 2
    What deficiencies are you finding with using `Process.Start`? – Oded Jan 26 '11 at 16:35
  • 1
    How about a batch file starting the process and using Process.Start to start the batch file? – CodingBarfield Jan 26 '11 at 16:36
  • The command line is coming from a configuration file and is provided as a whole. I just want to mimic the WIN+R functionality. I think even VBScript has a way to do what I need... – Stefan Koell Jan 27 '11 at 10:23

3 Answers3

4

Yes, you can launch cmd.exe with the full command-line you want to send as the arguments.

info.FileName = "cmd.exe";
info.Arguments = "app.exe /arg1:1 /arg2:true";
Adam Robinson
  • 177,794
  • 32
  • 275
  • 339
3

ProcessStartInfo.UseShellExecute makes Process.Start behave exactly like the Shell: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute.aspx

Felice Pollano
  • 32,038
  • 8
  • 71
  • 112
0

I've found the solution I've been looking for: Executing another program from C#, do I need to parse the "command line" from registry myself?

Thanks again for your help!

Community
  • 1
  • 1
Stefan Koell
  • 1,436
  • 3
  • 15
  • 24