Alan's Blog

"Yeah. I wrote a script that will do that."

Menu
  • About My Blog
Menu

My Windows 10 Fix

Posted on December 10, 2016December 10, 2016 by Alan

I had some issues with my Windows 10 computer at home.  I did some research, and came up with this batch file to freshen and check all of the operating system files.    Save this as Fix10.cmd (or Fix10.bat) and run it with admin rights.

@echo off
REM Fix10.cmd
REM Alan Kaplan www.akaplan.com/blog
REM This batch file automates the DISM restore health and SFC commands for Windows 10
REM 11/27/16

rem Test for Win 10
ver | find "10.0" > nul
IF %ERRORLEVEL%==0 (
    REM Echo Windows 10 found, continuing
) ELSE (
    ECHO This was written for Windows 10. Quitting.
    goto :eof
)

rem DISM requires elevation.  Rerun if not so
REM Peter Mortensen's method, http://stackoverflow.com/questions/7044985/how-can-i-auto-elevate-my-batch-file-so-that-it-requests-from-uac-administrator
net file 1>nul 2>nul && goto :Main || powershell -ex unrestricted -Command "Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~fnx0 %*'"
goto :eof

:Main
Echo Running DISM Restore Health
Title Running Windows 10 File Integrity Command 1 of 4
REM these are preliminary commands found on Technet not in KB article, below
Echo It will take several minutes for the commands to be completed.
%windir%\system32\Dism.exe /Online /Cleanup-Image /ScanHealth
Title Running Windows 10 File Integrity Command 2 of 4
%windir%\system32\Dism.exe /Online /Cleanup-Image /CheckHealth
REM commands and text from https://support.microsoft.com/en-us/kb/947821
Title Running Windows 10 File Integrity Command 3 of 4
DISM.exe /Online /Cleanup-image /Restorehealth
rem Important: When you run this command, DISM uses Windows Update to provide the files that are required to fix corruptions.
rem However, if your Windows Update client is already broken, use a running Windows installation as the repair source, 
rem or use a Windows side-by-side folder from a network share or from a removable media, 
rem such as the Windows DVD, as the source of the files. 
rem To do this, run the following command instead:
rem DISM.exe /Online /Cleanup-Image /RestoreHealth /Source:C:\RepairSource\Windows /LimitAccess
rem Note Replace the C:\RepairSource\Windows placeholder with the location of your repair source. 
echo It will take several minutes for the command operation to be completed.
Title Running Windows 10 File Integrity Command 4 of 4
sfc /scannow
echo Launching Windows Update now.  Please check for updates.  The repair log will open in notepad.
pause
REM open Windows Update dialog
explorer ms-settings:windowsupdate
start %windir%/Logs/CBS/CBS.log

Leave a Reply

You must be logged in to post a comment.

Search

Please Note

All the scripts are saved as .txt files. Newer files have a “View Script” button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use “Save Target As”. Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with version 3 or later.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient.  If you find a post error or a script which doesn’t work as expected, I appreciate being notified.  My email is my first name at the domain name, and you are welcome to contact me that way.

Tags

1E ACLS Active Directory ActiveDirectory ADSI Advanced Functions Audit Change Administrator Password COMObject Computer Groups DateTime Desktop DNS Excel FileScriptingObject Forms General GPO GPS Group Policy Hacks ISE Lockout logons NAV740 Nessus OU OU permissions Outlook Pick Folder Power PowerShell Powershell Scriptlets RDP SCCM schedule reboot Scripting Security Shell.Application user information VBA Windows Update WMI WordPress WPF

Categories

akaplan.com

  • Back to Home Page

Archives

Scripting Sites

  • A Big Pile of Small Things
  • Adam, the Automator
  • Art of the DBA
  • Ashley McGlone
  • Boe Prox
  • Carlo Mancini
  • DexterPOSH
  • Doug Finke
  • Jaap Brasser's Blog
  • JeffOps The Scripting Dutchman
  • Jonathan Medd's Blog
  • Keith Hill's Blog
  • LazyWinAdmin
  • Nana Lakshmanan
  • PowerShell Magazine
  • PowerShell Team Blog
  • PowerShell.org
  • PwrShell.net
  • Richard Siddaway's Blog
  • Ryan Yates' Blog
  • Skatterbrainz
  • The Lonely Administrator

SQL Site

  • Art of the DBA

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Alan's Blog | Theme by SuperbThemes

Terms and Conditions - Privacy Policy