hi
I want to run sfc.exe command in c++.
I use this code:
HINSTANCE SFCSevenRun() {
return ShellExecute(NULL, "runas", "C:\\WINDOWS\\system32\\cmd.exe",
"/k C:\\WINDOWS\\system32\\sfc.exe /scannow", 0, SW_SHOWNORMAL);
}
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?