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)?

3
  • 2
    What deficiencies are you finding with using Process.Start? Commented Jan 26, 2011 at 16:35
  • 1
    How about a batch file starting the process and using Process.Start to start the batch file? Commented Jan 26, 2011 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... Commented Jan 27, 2011 at 10:23

3 Answers 3

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"; 
Sign up to request clarification or add additional context in comments.

2 Comments

You'll probably need the /c switch to tell cmd.exe to execute app.exe.
I also thought about this solution but I don't like that the command window appears.
3

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

1 Comment

I'm aware of this property but this still requires me to pass in the command and the arguments separately.
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!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.