C#調用SFC.exe
ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/K sfc.exe /scannow");
startInfo.UseShellExecute = false;
startInfo.Verb = "runas";
Process.Start(startInfo);
運行結果:
為了使用 sfc 工具,你必須作為管理員運行控制台會話。
使用管理員權限打開VS,再次運行,運行結果:
Windows 資源保護無法啟動修復服務。
啟動其他軟件是可以的,比如ping.exe等,google也很少信息,在犄角旮旯看到這個帖子:http://www.cplusplus.com/forum/general/81883/
提問者自己解決了問題
I found the answer myself:
I created a project that compiled by 32bit compiler but my windows7 platform was 64bit and this did not work.
After that, I test this project in windows7 32bit and was OK. and I created project with 64bit compiler in windows7 64bit and that was OK too.
有道理
於是編譯的時候選擇x64作為目標平台,再次運行:
開始系統掃描。此過程將需要一些時間。
開始系統掃描的驗證階段。
驗證 2% 已完成。