Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliMD/3aa24f4a59c63fa32e24b768e002455b to your computer and use it in GitHub Desktop.
Save AliMD/3aa24f4a59c63fa32e24b768e002455b to your computer and use it in GitHub Desktop.
Manually Optimize/Clean/Compact Windows 10/11

Manually Optimize/Clean/Compact Windows 10/11

Enter Audit Mode by Pressing CTRL+SHIFT+F3

When you are prompted with Let's start with a region or Get going fast, or Personalize, or Customize Settings, or Setup Windows, press CTRL+SHIFT+F3 to switch to audit mode.

Delete recovery partition (with caution)

DiskPart
Select Disk 0
List Part
Select Part x (recovery)
Delete Partition Override
List Part
Select Part y (windows)
Extend
List Part
Exit

Install .Net Framework 3.5

DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:D:\sources\sxs

Update windows if you like

Anti­Spy for Windows 10⁠

https://www.ashampoo.com/en-us/antispy-for-windows-10

Remove all Appx (with caution)

Get-AppxPackage -AllUsers | Remove-AppxPackage

Get-AppxProvisionedPackage -online | Remove-AppxProvisionedPackage –online

Generalizing a Windows image (sysprep)

Download unattend.xml file to c:\ before continue.

Remember to change the password from the file.

c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /unattend:c:\unattend.xml /reboot

In virtual machine mode

c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /mode:vm /unattend:c:\unattend.xml /reboot

Activate Windows

Windows 10/11 Enterprice (HWID or Online KMS)

irm https://massgrave.dev/get | iex

Windows Server

slmgr.vbs /ipk KEY
slmgr /skms kms.technet24.ir
slmgr /ato

Native Image Generator (Ngen.exe)

Improves the performance of managed applications.

cd\
cd Windows\Microsoft.NET\Framework\v4 (and press tab)
ngen executequeueditems

Clean manager

Clears unnecessary files from your computer's hard disk.

cleanmgr /d c: /verylowdisk /autoclean

Deployment Image Servicing Management (DISM.exe)

Cleans unused files from the Side by Side component store.

dism /online /cleanup-image /startcomponentcleanup /resetbase

NTFS Compression (compact.exe)

Saves space on the Windows image by running the operating system and other system files from compressed files. This strategy reduces the number of IOPS required for storage with cache and has a negligible impact on the CPU.

compact /compactos:always

Disable SystemPaneSuggestionsEnabled

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SystemPaneSuggestionsEnabled /t REG_DWORD /d 0 /f

Disable hibernate

powercfg /h off

Other

sdelete64 -z c:

slmgr.vbs /ckms clears the name of the KMS server.

slmgr.vbs /ckhc disables KMS host caching.

ipconfig /release releases the IP address.

<?xml version="1.0" encoding="UTF-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<settings pass="specialize">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>net accounts /maxpwage:unlimited</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Path>net user Administrator /active:yes</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<TimeZone>Pacific Standard Time</TimeZone>
<ComputerName>*</ComputerName>
</component>
</settings>
<settings pass="oobeSystem">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<CopyProfile>false</CopyProfile>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<NetworkLocation>Work</NetworkLocation>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<ProtectYourPC>3</ProtectYourPC>
</OOBE>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Description>Local Administrator</Description>
<DisplayName>Administrator</DisplayName>
<Group>Administrators;Remote Desktop Users</Group>
<Name>Administrator</Name>
<Password>
<Value>Pass@1234</Value>
<PlainText>true</PlainText>
</Password>
</LocalAccount>
</LocalAccounts>
<AdministratorPassword>
<Value>
</Value>
<PlainText>true</PlainText>
</AdministratorPassword>
</UserAccounts>
<AutoLogon>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Username>Administrator</Username>
<Password>
<Value>
</Value>
<PlainText>true</PlainText>
</Password>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
<CommandLine>schtasks /change /TN "\Microsoft\Windows\RetailDemo\CleanupOfflineContent" /Disable</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<CommandLine>reg load "HKEY_USERS\temp" "%USERPROFILE%\..\Default User\NTUSER.DAT"</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>3</Order>
<CommandLine>reg ADD "HKEY_USERS\temp\Control Panel\International\User Profile" /v HttpAcceptLanguageOptout /t REG_DWORD /d 0x00000001 /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>4</Order>
<CommandLine>reg unload "HKEY_USERS\temp"</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>5</Order>
<CommandLine>reg ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v ShippedWithReserves /t REG_DWORD /d 0x00000000 /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>6</Order>
<CommandLine>reg ADD "HKLM\SOFTWARE\Policies\Microsoft\Internet Explorer\Security" /v "DisableSecuritySettingsCheck" /t "REG_DWORD" /D "00000001" /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>7</Order>
<CommandLine>reg ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1806" /t "REG_DWORD" /D "00000000" /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>8</Order>
<CommandLine>reg ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1806" /t "REG_DWORD" /D "00000000" /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>9</Order>
<CommandLine>reg ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Associations" /v "LowRiskFileTypes" /t "REG_SZ" /D ".exe" /f</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>20</Order>
<CommandLine>cmd /C del c:\Windows\System32\Sysprep\unattend.xml /Q</CommandLine>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>11</Order>
<CommandLine>schtasks /change /TN "\Microsoft\Windows\WindowsUpdate\Scheduled Start" /Disable</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
</unattend>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment