Skip to content

0xNixxy/fix-windows-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fix-windows-system

License: MIT

Made with Batch Scripting Made with PowerShell 5.1 Tested on Windows 11 25H2

Overview

This repo contains standalone scripts to automatically detect and repair corruption(s) found in the system components and filesystem of a Windows 11 operating system (OS). The scripts uses only tools that come pre-packaged with the Windows 11 Home OS and does not require installation of any third-party software.

For Command Prompt users, use FixWindowsSystem.bat.

For PowerShell users, use FixWindowsSystem.ps1. As PowerShell 5.1 is packaged together with Windows 11, this PowerShell script has been written to use only PowerShell 5.1 commands.

Windows system repair workflow

The script repairs Windows in the following steps:

  1. Remove unused driver packages in Windows using

    rundll32.exe pnpclean.dll,RunDLL_PnpClean /DRIVERS /MAXCLEAN
  2. Detect and repair errors found in Windows component store (WinSxS) using the Repair-WindowsImage cmdlet or Dism.exe tool.

  3. Detect and repair errors found in Windows system files using the sfc.exe tool. There seems to be no PowerShell equivalent for this tool.

  4. Detect and repair corruption in Windows file system using Repair-Volume cmdlet or chkdsk tool.

  5. Remove superseded versions of updated components in Windows component store using the Repair-Volume cmdlet or Dism.exe tool.

  6. Detect and repair errors found in disk volume using Optimize-Volume cmdlet or defrag tool.

    Note: If no errors are found in disk volume, the script will perform disk optimisation by executing defrag for HDD and retrim for SSD accordingly.

Usage guide for Command Prompt users

To use the batch file on your Windows 11 system

  1. Download FixWindowsSystem.bat to computer.

  2. Right-click on the batch file and select "Run as administrator". A UAC prompt will appear to request for elevation to run the script with Administrator privileges.

  3. Alternatively, open Command Prompt with Administrator privileges.

    FixWindowsSystem.bat

Usage guide for PowerShell users

Important

If your script is unable to execute properly on your Windows machine, you may need to relax your PowerShell Execution Policy or unblock your script from Smart App Control. See the sections below for more information on how to do this.

To use the PowerShell script on your Windows 11 system

  1. Download FixWindowsSystem.ps1 to your Downloads folder.

  2. Right-click on the script and select "Run with PowerShell". A UAC prompt will appear to request for elevation to run the script with Administrator privileges.

  3. Alternatively, open PowerShell Terminal with Administrator privileges and execute the script.

    .\FixWindowsSystem.ps1

How to set Bypass Policy on Local Machine

If you use the default PowerShell Execution Policy on your Windows machine, the policy for local machine is set to Undefined. This will cause PowerShell scripts to be blocked and they will not be able to execute locally your machine.

In order to execute PowerShell scripts locally on your Windows machine, you will need to perform a one-time relaxing of this policy using PowerShell Terminal with Administrator privileges with the following command.

Set-ExecutionPolicy -ExecutionPolicy Bypass

Verify that your execution policy for LocalMachine is updated to Bypass.

Get-ExecutionPolicy -List

The expected output should be similar to below.

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine          Bypass

How to unblock script from Smart App Control

When you download a PowerShell script and want to execute it on your machine, Smart App Control in your Windows may block the script from executing and show a security warning about running scripts downloaded from the internet.

If you right-click the PowerScript file to execute it, the security warning appears as a pop-up with the following message:

Smart App Control blocked a file that may be unsafe

This file was blocked because files of this type from the internet can be
dangerours.

Learn more

Alternatively, if you opened PowerShell Terminal and tried to execute the script, you will see the following security warning appear in the terminal:

Security warning
Run only scripts that you trust. While scripts from the internet can be
useful, this script can potentially harm your computer. If you trust this
script, use the Unblock-File cmdlet to allow the script to run without this
warning message. Do you want to run C:\...\FixWindowsSystem.ps1?

In both cases above, you can mark the script as "safe to run" with the command below to unblock the script from Smart App Control.

Unblock-File .\FixWindowsSystem.ps1

About

Windows script to fix issues and optimise performance for Windows system and filesystem.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors