0

I want to execute a string in c# as a .cmd. Is this possible without first saving it as a file on disk and then use Process.Start to execute the file? If so, please come with an example of how to do that in C#.

1
  • Thanks and sorry for duplicate. Couldn't find the right search phrase :) Commented Mar 17, 2014 at 16:39

1 Answer 1

3

I believe this can be done by simply using cmd.exe as your child process, redirecting StandardInput and simply feeding your string into this redirected StandardInput to make cmd.exe interpret it as batch and run it. The command echo dir | cmd.exe works and so I'd expect Process.Start to work as well.

Sign up to request clarification or add additional context in comments.

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.