无法在C ++中运行sfc.exe [英] can not run sfc.exe in c++
本文介绍了无法在C ++中运行sfc.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此代码:
/*
具有用户权限运行命令
*/
HINSTANCE SFCSevenRun(){
返回 ShellExecute(NULL," ," ,
" , 0 ,SW_SHOWNORMAL);
}
/*
未经用户许可运行命令
*/
HINSTANCE SFCXpRun(){
返回 ShellExecute(NULL," ," ,
" , 0 ,SW_SHOWNORMAL);
}
如果我在常规模式下运行cmd(使用 open 而不是 runas ),则会显示以下消息:
您必须是运行控制台会话的管理员才能使用sfc实用程序."
在XP中可以,但是在Windows 7中,当我以管理员身份运行时,我在cmd中收到此消息:
"Windows资源保护无法启动修复服务"
请帮我.如何解决此问题?
解决方案
我认为您可以右键单击程序,然后选择由管理员运行". Win7具有更有效的身份验证
hi
I want to run sfc.exe command in c++.
I use this code:
/*
Run Command with user permission
*/
HINSTANCE SFCSevenRun() {
return ShellExecute(NULL, "runas", "C:\\WINDOWS\\system32\\cmd.exe",
"/k C:\\WINDOWS\\system32\\sfc.exe /scannow", 0, SW_SHOWNORMAL);
}
/*
Run Command without user permission
*/
HINSTANCE SFCXpRun() {
return ShellExecute(NULL, "open", "C:\\WINDOWS\\system32\\cmd.exe",
"/k C:\\WINDOWS\\system32\\sfc.exe /scannow", 0, SW_SHOWNORMAL);
}
If I run cmd in usual mode (use open instead of runas ) I get this message:
"You must be an administrator running a console session in order to use the sfc utility."
In xp it is OK, but in windows 7 I receive this message in cmd when I run as admin:
"windows resource protection could not start the repair service"
Please Help me. How can I fix this problem?
解决方案
I think you can right click your program, and select "run by administrator". Win7 has more effective authentication
这篇关于无法在C ++中运行sfc.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文