0

I want to run SFC command in a cmd file. At the ende of the check i would like to verify whether SFC has found errors (that an error message can be displayed) or not. Unfortunately errorlevel seems not to be working with sfc - it always shows 0 in my experience, no matter if it found corrupted files or not.

Some ideas how to solve this?

Update: To be more precise what i want is this. The cmd starts some backupjobs etc. then starts the sfc/scannow. In case sfc found corrupted files and repaired them i want that some alert can be triggered and the cmd comes to a stopp, so that in the next morning i can see that something was fishy (I know that /scannow should already have fixed everything - but i want to have a look at this).Usually for this kind of "Errorhandling" i read out the %errorlevel% to find out if a command produced an error. But this is not possible with sfc since - in my experience - it always shows 0 for errorlevel no matter what. I'm looking now for a workaround. End of Update.

Greetings!

  • What do you mean verify if sfc has found errors? It either finds errors and tells you ( depending on the type of scan you performed ) or it detects the errors and proceeds to fix them. – Ramhound Aug 8 '14 at 11:03
  • Hi Ramhound, i tried to clarify. Added more Info in the Thread. – user54512 Aug 8 '14 at 14:41
  • Run findstr /c:"[SR]" C:\Windows\logs\CBS\CBS.log >sfcdetails.txt open the sfcdetails.txt and look if Windows is unable to restore files or if it was able to fix all issues. – magicandre1981 Aug 8 '14 at 17:44
  • to go wHi magicandre1981, going with findstr through the cbs.log is actually what i'm doing right now ;) The problem with this is that you might be missing something since you can not know all error-phrases (rerairing corrupted, repaired file...). That's why i wanted to know if there is a more "high level" way of doing that - more a yes or no type of answer... But since %errorlevel% seems not to be working (at least in my understanding) maybe that's not possible... – user54512 Aug 11 '14 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.