Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
On Executing a c# code/Batch file having Diskpart as a part of code, execution halts on Diskpart prompt or returns back. Further commands execution like list volume etc. doesn't execute. Is there any way to bypass the Diskpart or to proceed to further commands execution.

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
string strCmdLine;
strCmdLine = "/C " + "List volume";
System.Diagnostics.Process.Start("Diskpart.exe", strCmdLine);
process1.Close();


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 9-Mar-11 21:10pm
v2

1 solution

Probably, taking out the line:
C#
process1.Close();
will improve the situation.
Closing a process also terminates it if it hasn't finished...
 
Share this answer
 
Comments
sk saini 10-Mar-11 9:31am    
No its not working.
Sergey Alexandrovich Kryukov 10-Mar-11 13:07pm    
I know... it needs some work-around. What do you need from "Diskpart.exe" in this case? just to return of the text with volume info, is that right? You should have started your Question with that. Please answer, I think I know what to do...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900