How do I execute a cmd in C#, then in the same window execute another command that follows?

Posted by Ashh on Stack Overflow See other posts from Stack Overflow or by Ashh
Published on 2010-04-02T14:29:38Z Indexed on 2010/04/02 14:33 UTC
Read the original article Hit count: 276

Filed under:
|
|
|

Hey Guys,

Right what im trying to accomplish is a program that basically sets the active partition in 1 click, saving the effort time and skill of using cmd prompt etc.

I have looked into the System.Management name space but couldn't work out how to use it :(

So i have resorted to using CMD, i have got a module application written in C# and basically i want to run "DISKPART" which then starts the diskpart in the cmd window, then i want to ask it to "Select disk 0" followed by "select partition 1" finally followed by "active".

Doing this in CMD yourself works fine but with an application its proved to be awkward :( What ive managed to get it to do is run DiskPart fine in one window with Process.Start, then get it to open a new window and run the next piece of code but because the new window hasnt ran the diskpart cmd it doesnt work >:(

Any suggestions?

Thanks!

Ash

© Stack Overflow or respective owner

Related posts about c#

Related posts about cmd