Gewoo
Gewoo

Reputation: 457

execute batch command in c#

I would like to run a batch command in c# code.

I tried this code but it only pops up cmd but I want it to pop up cmd and displays "Hello World".

Process.Start("cmd", "echo Hello World");

Is it possible to do this?

Upvotes: 1

Views: 318

Answers (1)

adv12
adv12

Reputation: 8551

Try this:

Process.Start("cmd", "/K echo Hello World");

(Note the "/K")

based on this reference for cmd.exe

Upvotes: 5

Related Questions