Solved Making sfc /scannow .bat file

David Bailey

Banned
Messages
10,485
Location
Harrisonburg, Va.
The following images show how to make a batch file for sfc /scannow that opens with one or two clicks:

They are numbered in the order of reading them.

I numbered them because they never show up in the proper order when attached. :(


001.png003.png005.png007.png008.png
 
Last edited:
Thanks for sharing the info. However, a simple way to create a bat file is to right click on the desktop->New->Text Document and enter 2 statements on separate lines: sfc /scannow, pause then save it as RunSFC.bat or whatever you name it.

NOTE: you need to put a pause statement after sfc /scannow so that the user will have a chance to read the output message, otherwise the command windows just simply closes.
 
It should be on separate lines:
sfc /scannow
pause

OR:
@ sfc /scannow
@ pause

OR:
@ sfc /scannow & pause

By adding '@' the command will not be echoed in the command windows.
adding & if you want multiple commands in one line
 
Last edited:
Learned new stuff

I added the PAUSE & it kept the window open.
It said to press any key to continue.
I pressed Space bar & the window closed. :)

Untitled.png

A note to Brink --- I studied the adding of images in proper order & figured it out.
Thanks for the help. :)

Also, I figured out making test posts without posting them.
I just Preview the test post & make changes as needed & when done close the window.
I don't clutter up the forum with tests.
 
Last edited:
Added new Lines to .bat code

Code:
sfc /scannow
PAUSE
Dism /Online /Cleanup-Image /RestoreHealth
PAUSE

Untitled.png

The DISM command actually fixes things SFC can't fix.
See picture:

Untitled (2).png

Before running it, SFC found un-fixable problems.


After running it, All problems were fixed. :)

See picture:

Untitled.png

If you run sfc /scannow as in the .bat file & see problems not fixed press any key & the DISM command will run & fix the problems. :)

Or to be more efficient you could add another sfc /scannow & pause:

Code:
sfc /scannow
PAUSE
Dism /Online /Cleanup-Image /RestoreHealth
PAUSE
sfc /scannow
PAUSE

If you wanted to run sfc /scannow again just to be sure things are fixed. :)
 
Last edited:
Hi, David. Like I wrote you > This is very handy. Thanks for the additions. :thumb:

Is it possible to omit the pause so as to start one right after the other?
 
Added new Lines to .bat code

Code:
sfc /scannow
PAUSE
Dism /Online /Cleanup-Image /RestoreHealth
PAUSE

View attachment 19490

The DISM command actually fixes things SFC can't fix.
See picture:

View attachment 19491

Before running it, SFC found un-fixable problems.


After running it, All problems were fixed. :)

See picture:

View attachment 19489

If you run sfc /scannow as in the .bat file & see problems not fixed press any key & the DISM command will run & fix the problems. :)

Or to be more efficient you could add another sfc /scannow & pause:

Code:
sfc /scannow
PAUSE
Dism /Online /Cleanup-Image /RestoreHealth
PAUSE
sfc /scannow
PAUSE

If you wanted to run sfc /scannow again just to be sure things are fixed. :)
How can you restart the system before it runs the dism command
 
I would like to have such a batch file in Windows 10; do you know if what works in Win8, can't work in Win10 ? If so what code modification is required ?
 
I would like to have such a batch file in Windows 10; do you know if what works in Win8, can't work in Win10 ? If so what code modification is required ?
Yes, the same batch files will work in Win10 and Win11. Note that to use the SFC and DISM commands you need to run the batch file as an administrator. To make life simple I have put shortcuts to my batch files on the desktop, and have set their Advanced Properties to 'Run as administrator'.

1724947249064.png
 
It has (obviously) taken me time to get round to trying and replying. It worked so well right from the start that I can not imagine why I posted the question. But I CAN say that 'running it as administrator' makes ALL the difference.
 
Last edited:
Back
Top