Jump to content

WinFix batch script for repairing many common Windows related problems

I've made a short script that uses CHKDSK, DISM, and SFC to fix many common Windows-related** problems.

The download is at the bottom and here's the whole "code" so you can see it's not something malicious. I've tried explaining each step.

The script needs to be run as administrator in order to work properly.

Hope this helps at least some of you.

 

** This script does not apply to Windows 7, some commands are newer. Should work fine on Win 10 and 8.1.

 

@echo off
color 0C
title WinFix script for LinusTechTips forum members made by 191x7
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo ! The script contains 4 procedures.
echo ! The 1st procedure checks the disk - regular Checkdisk - 1 phase
echo ! The 2nd procedure checks and repairs the Windows Component Files - 2 phases
echo ! The 3rd procedure checks and repairs the Windows image - 4 phases
echo ! The 4th procedure uses System file check to check system files - 1 phase
echo ! In Windows 7 only CHKDSK and SFC work, the rest is new (Windows 8 +)
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo -------------------------------------------------
echo Checking the Windows partition - procedure 1 of 4
echo -------------------------------------------------
chkdsk c: /scan
echo -------------------------------------------
echo If it finds some problems, run chkdsk c: /f
echo -------------------------------------------
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo ------------------------------------------------
echo Windows component files check - procedure 2 of 4
echo ------------------------------------------------
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
echo --------------------------------------------------
echo Phase 1 of 2 completed
echo --------------------------------------------------
Dism.exe /online /Cleanup-Image /SPSuperseded
echo --------------------------------------------------
echo Phase 2 of 2 completed
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo --------------------------------------------------------------
echo Checking the integrity of the Windows image - procedure 3 of 4
echo --------------------------------------------------------------
DISM /Online /Cleanup-Image /CheckHealth
echo --------------------------------------------------
echo Phase 1 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /ScanHealth
echo --------------------------------------------------
echo Phase 2 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /RestoreHealth
echo --------------------------------------------------
echo Phase 3 of 3 completed 
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo -------------------------------------------------
echo Running System file check - procedure 4 of 4
echo -------------------------------------------------
sfc /scannow
echo --------------------------------------------------------------------------------
echo If SFC found some errors and could not repair, re-run the script after a reboot.
echo --------------------------------------------------------------------------------
echo PRESS F TO PAY RESPECTS.
pause >null
del null

 

LTT WinFix by 191x7 v13.03.19.bat

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 weeks later...
Just now, KlutchPhreek said:

how do I run it as admin?

Right click on it and "Run as Administrator".

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

Just now, KlutchPhreek said:

i cannot open anything as administrator 

Are you not the administrator on your own PC?

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

 

4 minutes ago, 191x7 said:

Are you not the administrator on your own PC?

i am pretty sure i am, it was fine like a month ago then all of the sudden i have been getting all of these problems.

Edit: just checked yes i am admin

 
Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, KlutchPhreek said:

 

i am pretty sure i am, it was fine like a month ago then all of the sudden i have been getting all of these problems.

 

Then let's continue this back in your thread.

 

Try a clean install of Windows, you might have some malware or something.

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

Let me fix that admin access option for your script, so that it will automatically ask for admin rights when it's run.

Whole code here :
 

@echo off
color 0C
title WinFix script for LinusTechTips forum members made by 191x7 - Admin Fix from Screen
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo ! The script contains 4 procedures.
echo ! The 1st procedure checks the disk - regular Checkdisk - 1 phase
echo ! The 2nd procedure checks and repairs the Windows Component Files - 2 phases
echo ! The 3rd procedure checks and repairs the Windows image - 4 phases
echo ! The 4th procedure uses System file check to check system files - 1 phase
echo ! In Windows 7 only CHKDSK and SFC work, the rest is new (Windows 8 +)
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo PRESS ANY KEY TO CONTINUE.
pause >null

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

del null
cls
echo -------------------------------------------------
echo Checking the Windows partition - procedure 1 of 4
echo -------------------------------------------------
chkdsk c: /scan
echo -------------------------------------------
echo If it finds some problems, run chkdsk c: /f
echo -------------------------------------------
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo ------------------------------------------------
echo Windows component files check - procedure 2 of 4
echo ------------------------------------------------
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
echo --------------------------------------------------
echo Phase 1 of 2 completed
echo --------------------------------------------------
Dism.exe /online /Cleanup-Image /SPSuperseded
echo --------------------------------------------------
echo Phase 2 of 2 completed
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo --------------------------------------------------------------
echo Checking the integrity of the Windows image - procedure 3 of 4
echo --------------------------------------------------------------
DISM /Online /Cleanup-Image /CheckHealth
echo --------------------------------------------------
echo Phase 1 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /ScanHealth
echo --------------------------------------------------
echo Phase 2 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /RestoreHealth
echo --------------------------------------------------
echo Phase 3 of 3 completed 
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo -------------------------------------------------
echo Running System file check - procedure 4 of 4
echo -------------------------------------------------
sfc /scannow
echo --------------------------------------------------------------------------------
echo If SFC found some errors and could not repair, re-run the script after a reboot.
echo --------------------------------------------------------------------------------
echo PRESS F TO PAY RESPECTS.
pause >null
del null

 

LTT WinFix by 191x7 - Screen v10.04.19.bat

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Screen said:

Let me fix that admin access option for your script so that it will automatically ask for admin rights when it's run.
 

LTT WinFix by 191x7 - Screen v10.04.19.bat

 

Thank you! :)

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 years later...

Minor edit to set chkdsk to actually fix any errors found while scanning, and to use the %SYSTEMROOT% variable (a tiny fraction of computers will have Windows on a different drive letter, or perhaps the users starts out under a different drive where they saved the batch file.  %SYSTEMROOT% fixes that)


EDIT: see blurb at the end for a (supposedly better?) method of getting admin as well.  I didn't bother putting that in, though.  It's just in case you found it interesting.

Quote
cls
echo -------------------------------------------------
echo Checking the Windows partition and fixing if necessary - procedure 1 of 4
echo -------------------------------------------------
chkdsk %SYSTEMDRIVE% /f
echo -------------------------------------------
echo
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null

 

On 4/9/2019 at 11:23 PM, Screen said:

Let me fix that admin access option for your script, so that it will automatically ask for admin rights when it's run.

Whole code here :
 

@echo off
color 0C
title WinFix script for LinusTechTips forum members made by 191x7 - Admin Fix from Screen
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo ! The script contains 4 procedures.
echo ! The 1st procedure checks the disk - regular Checkdisk - 1 phase
echo ! The 2nd procedure checks and repairs the Windows Component Files - 2 phases
echo ! The 3rd procedure checks and repairs the Windows image - 4 phases
echo ! The 4th procedure uses System file check to check system files - 1 phase
echo ! In Windows 7 only CHKDSK and SFC work, the rest is new (Windows 8 +)
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo PRESS ANY KEY TO CONTINUE.
pause >null

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

del null
cls
echo -------------------------------------------------
echo Checking the Windows partition - procedure 1 of 4
echo -------------------------------------------------
chkdsk c: /scan
echo -------------------------------------------
echo If it finds some problems, run chkdsk c: /f
echo -------------------------------------------
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo ------------------------------------------------
echo Windows component files check - procedure 2 of 4
echo ------------------------------------------------
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
echo --------------------------------------------------
echo Phase 1 of 2 completed
echo --------------------------------------------------
Dism.exe /online /Cleanup-Image /SPSuperseded
echo --------------------------------------------------
echo Phase 2 of 2 completed
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo --------------------------------------------------------------
echo Checking the integrity of the Windows image - procedure 3 of 4
echo --------------------------------------------------------------
DISM /Online /Cleanup-Image /CheckHealth
echo --------------------------------------------------
echo Phase 1 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /ScanHealth
echo --------------------------------------------------
echo Phase 2 of 3 completed
echo --------------------------------------------------
DISM /Online /Cleanup-Image /RestoreHealth
echo --------------------------------------------------
echo Phase 3 of 3 completed 
echo PRESS ANY KEY TO CONTINUE.
pause >null
del null
cls
echo -------------------------------------------------
echo Running System file check - procedure 4 of 4
echo -------------------------------------------------
sfc /scannow
echo --------------------------------------------------------------------------------
echo If SFC found some errors and could not repair, re-run the script after a reboot.
echo --------------------------------------------------------------------------------
echo PRESS F TO PAY RESPECTS.
pause >null
del null

 

LTT WinFix by 191x7 - Screen v10.04.19.bat

 

 

Here's the improved non-vbs way to get admin:

 

Quote
::::::::::::::::::::::::::::::::::::::::::::
:: Elevate.cmd - Version 4
:: Automatically check & get admin rights
:: see "https://stackoverflow.com/a/12264592/1016343" for description
::::::::::::::::::::::::::::::::::::::::::::
 @echo off
 CLS
 ECHO.
 ECHO =============================
 ECHO Running Admin shell
 ECHO =============================

:init
 setlocal DisableDelayedExpansion
 set cmdInvoke=1
 set winSysFolder=System32
 set "batchPath=%~dpnx0"
 rem this works also from cmd shell, other than %~0
 for %%k in (%0) do set batchName=%%~nk
 set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
 setlocal EnableDelayedExpansion

:checkPrivileges
  NET FILE 1>NUL 2>NUL
  if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
  if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
  ECHO.
  ECHO **************************************
  ECHO Invoking UAC for Privilege Escalation
  ECHO **************************************

  ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  ECHO args = "ELEV " >> "%vbsGetPrivileges%"
  ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
  ECHO Next >> "%vbsGetPrivileges%"
  
  if '%cmdInvoke%'=='1' goto InvokeCmd 

  ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  goto ExecElevation

:InvokeCmd
  ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
  ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"

:ExecElevation
 "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
 exit /B

:gotPrivileges
 setlocal & cd /d %~dp0
 if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)

 ::::::::::::::::::::::::::::
 ::START
 ::::::::::::::::::::::::::::
 REM Run shell as admin (example) - put here code as you like
 ECHO %batchName% Arguments: P1=%1 P2=%2 P3=%3 P4=%4 P5=%5 P6=%6 P7=%7 P8=%8 P9=%9
 cmd /k

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, 0x6A7232 said:

Minor edit to set chkdsk to actually fix any errors found while scanning, and to use the %SYSTEMROOT% variable (a tiny fraction of computers will have Windows on a different drive letter, or perhaps the users starts out under a different drive where they saved the batch file.  %SYSTEMROOT% fixes that)


EDIT: see blurb at the end for a (supposedly better?) method of getting admin as well.  I didn't bother putting that in, though.  It's just in case you found it interesting.

 

 

Here's the improved non-vbs way to get admin:

 

 

Wouldn't /f ask the user for a reboot to check the drive?

 

I have an upgraded version of the script but all the descriptions for the user are in Croatian. I might translate it to English and post it here.

 

Thanks for all the input and improvements.

M.S.C.E. (M.Sc. Computer Engineering), IT specialist in a hospital, 30+ years of gaming, 20+ years of computer enthusiasm, Geek, Trekkie, anime fan

  • Main PC: AMD Ryzen 7 5800X3D - EK AIO 360 D-RGB - Arctic Cooling MX-4 - Asus Prime X570-P - 4x8GB DDR4 3200 HyperX Fury CL16 - Sapphire AMD Radeon 6950XT Nitro+ - 1TB Kingston Fury Renegade - 2TB Kingston Fury Renegade - 512GB ADATA SU800 - 960GB Kingston A400 - Seasonic PX-850 850W  - custom black ATX and EPS cables - Fractal Design Define R5 Blackout - Windows 11 x64 23H2 - 3 Arctic Cooling P14 PWM PST - 5 Arctic Cooling P12 PWM PST
  • Peripherals: LG 32GK650F - Dell P2319h - Logitech G Pro X Superlight with Tiger Ice - HyperX Alloy Origins Core (TKL) - EndGame Gear MPC890 - Genius HF 1250B - Akliam PD4 - Sennheiser HD 560s - Simgot EM6L - Truthear Zero - QKZ x HBB - 7Hz Salnotes Zero - Logitech C270 - Behringer PS400 - BM700  - Colormunki Smile - Speedlink Torid - Jysk Stenderup - LG 24x External DVD writer - Konig smart card reader
  • Laptop: Acer E5–575G-386R 15.6" 1080p (i3 6100U + 12GB DDR4 (4GB+8GB) + GeForce 940MX + 256GB nVME) Win 10 Pro x64 22H2 - Logitech G305 + AAA Lithium battery
  • Networking: Asus TUF Gaming AX6000 - Arcadyan ISP router - 35/5 Mbps vDSL
  • TV and gadgets: TCL 50EP680 50" 4K LED + Sharp HT-SB100 75W RMS soundbar - Samsung Galaxy Tab A8 10.1" - OnePlus 9 256GB - Olymous Cameda C-160 - GameBoy Color 
  • Streaming/Server/Storage PC: AMD Ryzen 5 3600 - LC-Power LC-CC-120 - MSI B450 Tomahawk Max - 2x4GB ADATA 2666 DDR4 - 120GB Kingston V300 - Toshiba DT01ACA100 1TB - Toshiba DT01ACA200 2TB - 2x WD Green 2TB - Sapphire Pulse AMD Radeon R9 380X - 550W EVGA G3 SuperNova - Chieftec Giga DF-01B - White Shark Spartan X keyboard - Roccat Kone Pure Military Desert strike - Logitech S-220 - Philips 226L
  • Livingroom PC (dad uses): AMD FX 8300 - Arctic Freezer 64 - Asus M5A97 R2.0 Evo - 2x4GB DDR3 1833 Kingston - MSI Radeon HD 7770 1GB OC - 120GB Adata SSD - 500W Fractal Design Essence - DVD-RW - Samsung SM 2253BW - Logitech G710+ - wireless vertical mouse - MS 2.0 speakers
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×