-
-
Save eplord/a6bdc4c381c7893d23fd908b7e8853bb to your computer and use it in GitHub Desktop.
Fix windows update using this script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal | |
| :: Function to calculate checksum of a file | |
| :checksum | |
| setlocal | |
| set "file=%1" | |
| certutil -hashfile "%file%" MD5 | findstr /v /c:"CertUtil" | findstr /v /c:"MD5" | findstr /v /c:"%file%" | |
| endlocal & exit /b %errorlevel% | |
| :: Display License Header and Pause for 5 Seconds | |
| echo ################################################################### | |
| echo ## COSLA- Corespace Open Source License Agreement ## | |
| echo ## Feburary 02, 2024 - #202402021013 ## | |
| echo ## By Corespace ## | |
| echo ################################################################### | |
| timeout /t 3 >nul | |
| cls | |
| :menu | |
| :: Display Options | |
| echo 1. DISM /Online /Cleanup-Image /RestoreHealth | |
| echo 2. sfc /scannow | |
| echo 3. DISM and sfc | |
| :: Calculate the checksum of the existing script | |
| call :checksum "your_script_name.bat" | |
| set "current_checksum=%errorlevel%" | |
| :: Download the updated script from GitHub | |
| curl -o temp_script.bat https://gist.githubusercontent.com/AsP3X/b956ececa5fef34844b3e5fb298567c8/raw/4a5cc10d105fe48c27b5d9ca25809977fba5d9ab/FixWinUp.bat | |
| :: Calculate the checksum of the downloaded script | |
| call :checksum "temp_script.bat" | |
| set "new_checksum=%errorlevel%" | |
| :: Compare the checksums and update the script if they are different | |
| if %new_checksum% neq %current_checksum% ( | |
| echo 4. Update Script | |
| ) | |
| :: Clean up the temporary script file | |
| del temp_script.bat | |
| echo 5. Close Script | |
| set /p option=Select an option: | |
| if %option%==1 call :Option_1 | |
| if %option%==2 call :Option_2 | |
| if %option%==3 call :Option_3 | |
| if %option%==4 call :Update_Script | |
| if %option%==5 exit | |
| goto menu | |
| :Update_Script | |
| echo Updating the script... | |
| copy /y "temp_script.bat" "your_script_name.bat" | |
| echo Script updated successfully. | |
| timeout /t 5 >nul | |
| goto menu | |
| :: Define Functions for Each Option | |
| :Option_1 | |
| echo Running DISM command... | |
| @REM cmd /c "DISM /Online /Cleanup-Image /RestoreHealth" | |
| cmd /c "dism /online /cleanup-image /restorehealth /LimitAccess" | |
| if %errorlevel% equ 0 (echo DISM command completed successfully.) else (echo An error occurred running the DISM command.) | |
| timeout /t 5 >nul | |
| goto menu | |
| :Option_2 | |
| echo Running sfc command... | |
| cmd /c "sfc /scannow" | |
| if %errorlevel% equ 0 (echo sfc command completed successfully.) else (echo An error occurred running the sfc command.) | |
| timeout /t 5 >nul | |
| goto menu | |
| :Option_3 | |
| echo Running DISM command... | |
| call :Option_1 | |
| echo Running sfc command... | |
| call :Option_2 | |
| if %errorlevel% equ 0 (echo Both commands completed successfully.) else (echo An error occurred running one or both of the commands.) | |
| timeout /t 5 >nul | |
| goto menu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment