Solved How to Manually Do SFC's Job?

Virucyde

Banned
Local time
9:28 AM
Messages
5
I do a lot of work on customer machines at a computer shop, and one of the most frustrating issues I run into is when I run SFC on a computer and it reports that it found errors and was unable to fix them.

Originally I intended to write a program to automatically pull the [SR] reported files from the installation media and replace the broken ones on the system, however, when I run the command from the tutorial:

findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log

After an unsuccessful SFC attempt, even when it reports files that could not be fixed, I never turn up anything, anyone know why I don't get the [SR] tags in my CBS.log?
 

My Computer My Computer

OS
Windows 7 Home Premium x64

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
I've tried using both the command I posted and the exact one in the tutorial, if [SR] tags were in the files, mine should output the lines to the command prompt, and the tutorial's should output them to the text file, in both cases, on multiple computers, the commands return nothing, and a search of the CBS.log file shows no [SR] tags.

One piece of information that might be helpful is that I think most of the times I've attempted this, it's been using the /offwindir and /offbootdir commands from a PE, is the CBS.log file only generated if SFC is run in the OS being scanned?
 

My Computer My Computer

OS
Windows 7 Home Premium x64
Yeah, try running SFC in Windows 7 to see what it gives you afterwards.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
What about cases where the computer is unable to boot at all? This tends to be when I'm using SFC in the first place :/
 

My Computer My Computer

OS
Windows 7 Home Premium x64

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Okay, so to summarize what I got out of that, in my PE environment in order to get SFC logs, I'd need to:

Assuming the offline Windows drive is drive F:

Set the variable for the log file, so SFC doesn't attempt to store to log to the read-only media:
set WINDOWS_TRACING_LOGFILE=F:\TEMP\CBS.log

Run SFC with offline parameters:
sfc /scannow /offbootdir=F: /offwindir=F:\Windows

Once that command has finished, it's output should be logged to F:\TEMP\CBS.log, or wherever else you specified.
So to pull the errors out of the file, run:
findstr /c:"[SR]" F:\TEMP\CBS.log

This will output all error lines to the command prompt, if you want that output to go to a file instead, run:
findstr /c:"[SR]" F:\TEMP\CBS.log > F:\TEMP\sfcdetails.txt

Now your details regarding the failed repairs should be contained in F:\TEMP\sfcdetails.txt

Hopefully anyone Googling how to use SFC from WinPE in the future will find this helpful!

Also, thanks Brink, I appreciate the help, very fast, very effective :)
 

My Computer My Computer

OS
Windows 7 Home Premium x64
Correct. That's what I got from that post as well. I prefer the sfcdetails.txt to make it easier to read though.

Please let us know how it works for you. :)
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Also, according to Window's documentation on SFC:

On Windows Vista only, you can set the WINDOWS_TRACING_LOGFILE environment variable to the location of a valid directory to receive a log file.

Unfortunately I can't test it now, but I'd guess that in my above example, F:\TEMP would already need to exist, so the command:
mkdir F:\TEMP

Might be necessary before running the other commands, just an afterthought, I'll edit that post when I get another chance to test it out.
 

My Computer My Computer

OS
Windows 7 Home Premium x64
Back
Top