1

Hi everyone right now I'm trying to create my own program which can make VHD files and mount them all via C# my problem right know is that I don't know how to pass arguments to diskpart.exe all I have now is this:

Process.Start("diskpart.exe", @"create vdisk file=C:\windows.vhd maximum=25600 type=fixed");

another doubt I have is that after running this piece of code a cmd is open and the diskpart also How can I hide the CMD window? or close it?

TLo
  • 11
  • 3
  • Keep your questions separate... first problem: what exactly is your problem? – musefan Mar 16 '17 at 14:24
  • My main problem is How to pass arguments to diskpart.exe using Process in C# ? – TLo Mar 16 '17 at 14:32
  • Your code appears to be the correct method for passing parameters : https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx so what is going wrong? – PaulF Mar 16 '17 at 14:46
  • See this for hiding the command window : http://stackoverflow.com/questions/6857019/how-to-start-process-hidden & http://stackoverflow.com/questions/14274360/want-to-hide-the-cmd-prompt-screen – PaulF Mar 16 '17 at 14:49
  • @PaulF Yes it appears to be correct but if you run it nothing happens – TLo Mar 16 '17 at 15:13
  • Possibly because DiskPart needs to be run in administrator mode. (See here in VB.net http://stackoverflow.com/questions/16804103/run-another-program-as-admin-vb-net - should be easy to convert to C#. Note does always prompt) Have you tried running the command yourself. – PaulF Mar 16 '17 at 16:09

0 Answers0