简体   繁体   English

如何在C#中没有命令提示符的情况下在驱动器上运行chkdsk

[英]How to run chkdsk on drive without command prompt in c#

I searched on internet and found many possible ways of running chkdsk utility in c# using cmd.exe as file name and passing command as /c chkdsk drive_letter:/f /x 我在互联网上搜索,发现使用cmd.exe作为文件名并以/ c chkdsk drive_letter传递命令的方式在C#中运行chkdsk实用程序的许多可能方式:/ f / x

But I want to run chkdsk utility on drive ,without involvement of cmd.exe ie; 但是我想在驱动器上运行chkdsk实用程序,而无需使用cmd.exe。 Purely using internal features of c#. 纯粹使用c#的内部功能。

Your suggestions are greatly appreciated. 非常感谢您的建议。

Chkdsk is a console application. Chkdsk是一个控制台应用程序。 So how do you wanna start a console application without the console? 那么,如何在没有控制台的情况下启动控制台应用程序呢? The only thing you can do is hiding the window from the user. 您唯一可以做的就是向用户隐藏窗口。

As you for sure already noticed: MSDN - Chkdsk 如您所知,您已经注意到: MSDN-Chkdsk
According the console-window: 根据控制台窗口:

startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;

This together should bring you to your goal. 这将使您实现目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM