I'm new here and I wanted to write a C++ source code that executes the command:
sfc.exe /scannow
But it doesn't work. Windows-resource protection can't start repair service.
I'm a student and I'm in my 10th grade and I do not have computer science at school, so I wanted to ask the question here.
Here is my code excerpt:
#include<stdlib.h>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
system("sfc.exe /scannow");
}
The compiler brings no errors. I am using the GNU/GCC compiler, Windows 10 1803 and Code::Blocks(IDE)
I hope you can understand it :)
If you are using 64 bit system but your compiler is 32 bit means you will get this error. If you are using visual studio c++ and your pc is 64 bit system means change the platform to 64 bit.
For more information, ref this answer https://stackoverflow.com/a/20872354/6599346
Your code works, if you delete the #
before main()
and using namespace
and just for completion I added return 0;
at the end.
Code:
#include<stdlib.h>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
system("sfc.exe /scannow");
return 0;
}
Run the code with administrator rights and everything should be okay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With