Skip to content

Instantly share code, notes, and snippets.

@kajott
Last active April 9, 2024 08:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kajott/05b84fb630b4bc6c90337131f320a5c9 to your computer and use it in GitHub Desktop.
Save kajott/05b84fb630b4bc6c90337131f320a5c9 to your computer and use it in GitHub Desktop.
Windows 10/11 Setup Script
@echo off
@rem "This little script sets a few useful settings in Windows 10 that most"
@rem "serious users are likely to want; scroll through the script for details"
@rem "and disable sections you don't want."
@rem "Usage:"
@rem "Just save this file as a .bat or .cmd file and run it (with"
@rem "Administrator privileges!). You will need to re-run it after larger"
@rem "updates, as these tend to overwrite some of the settings or re-create"
@rem "files that are deliberately deleted by the script."
@rem "As a rule of thumb, re-run the script when the 'desktop.ini' icon"
@rem "reappears on the desktop."
@rem "First, some hints to settings that are *not* set by this script."
@rem "Win11: give this script permission to disable 'Start' and 'Catalog' in the Explorer:"
@rem "- regedit, right-click on HKCR\CLSID\{f874310e-..., permissions, advanced, change owner to Administrators"
@rem " and also give Administrators full access"
@rem "- same for CLSID\{e88865ea-... and HKCR\WOW6432Node\CLSID\..."
@rem "Allow symlink creation:"
@rem "- secpol.msc -> Local Policies -> User Rights Assignment -> Create symbolic links"
@rem " -> add 'Everybody'"
@rem "Autologin:"
@rem "- HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device\DevicePasswordLessBuildVersion = 0"
@rem "- run netplwiz, uncheck "users must logon with pwd", click OK, enter password one last time"
@rem "Configure Desktop icons:"
@rem "- Settings -> Personalization -> Themes -> Related Settings -> Desktop icon settings"
@rem "Disable Automatic Driver Download: [MIGHT BE OUTDATED]"
@rem "- Win+Pause -> Hardware -> Device Install Settings"
@rem "- HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/DriverSearching/SearchOrderConfig = 0"
@rem "Get rid of "Camera Roll" and "Saved Pictures":"
@rem "- Configure them away in %APPDATA%/Microsoft/Windows/Libraries"
@rem "Tame Defender: [MIGHT BE OUTDATED]"
@rem "- HKLM\Software\Policies\Microsoft\Windows Defender\DisableRoutinelyTakingAction:DWORD=1"
@rem "Repair Windows Spotlight:"
@rem "- Settings -> Privacy -> Background apps -> [X] Allow apps to run,"
@rem " but unselect all *except* Microsoft Edge and Settings"
@echo ***** checking administrator privileges
net file >nul 2>nul
@if errorlevel 1 (
@echo This script should be run with administrator privileges.
@echo Press ^^C and Y now or close this window to exit,
@echo or press Enter to continue without administrator privileges.
@pause
)
@echo.
@echo ***** make Explorer windows open This PC instead of Quick Access
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 1 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 1 /f /reg:64
@echo.
@echo ***** disable thumbnails in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v IconsOnly /t REG_DWORD /d 1 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v IconsOnly /t REG_DWORD /d 1 /f /reg:64
@echo.
@echo ***** show hidden files in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f /reg:64
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f /reg:64
@echo.
@echo ***** show file extensions in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f /reg:64
@echo.
@echo ***** open Explorer windows in separate processes
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v SeparateProcess /t REG_DWORD /d 0 /f /reg:32
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v SeparateProcess /t REG_DWORD /d 0 /f /reg:64
@echo.
@echo ***** use standard context menus in Win11 Explorer
reg add HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /ve /d "" /f /reg:32
reg add HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /ve /d "" /f /reg:64
@echo.
@echo ***** hide OneDrive from Explorer
reg add HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:32
reg add HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:64
@rem "similar for Dropbox, if desired: UUID starts with E31EA727"
@echo.
@echo ***** hide WSL2 from Explorer
reg add HKCR\CLSID\{B2B4A4D1-2754-4140-A2EB-9A76D9D7CDC6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:32
reg add HKCR\CLSID\{B2B4A4D1-2754-4140-A2EB-9A76D9D7CDC6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:64
@echo.
@echo ***** hide Catalog from Explorer (Win11)
reg add HKCR\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:32
reg add HKCR\CLSID\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:64
@echo.
@echo ***** hide Start from Explorer (Win11)
reg add HKCR\CLSID\{f874310e-b6b7-47dc-bc84-b9e6b38f5903} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:32
reg add HKCR\CLSID\{f874310e-b6b7-47dc-bc84-b9e6b38f5903} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f /reg:64
@echo.
@echo ***** hide removable drives from Explorer top-level
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83} /f /reg:32
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83} /f /reg:64
@echo.
@echo ***** remove folder shortcuts from This PC
@rem Pictures
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem Videos
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem Downloads
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem Music
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem Desktop
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem Documents
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@rem 3D Objects
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag /f /reg:64
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:32
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag /v ThisPCPolicy /t REG_SZ /d Hide /f /reg:64
@echo.
@echo ***** Disable web search in Start Menu
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /v BingSearchEnabled /t REG_DWORD /d 0 /f
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /v AllowCortana /t REG_DWORD /d 0 /f
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search /v CortanaConsent /t REG_DWORD /d 0 /f
@echo.
@echo ***** remove desktop.ini from Desktop
del /ah /f %USERPROFILE%\Desktop\desktop.ini %PUBLIC%\Desktop\desktop.ini
@echo.
echo ***** remove desktop.ini from customized default folders (to avoid localization)
@rem Note: We only do that if the user deliberately moved the folder out of
@rem their profile folder, under the assumption that they did that to
@rem choose their own name for these folders, and that they don't want
@rem the names to be mangled by Explorer.
@rem Documents
powershell -Command "$x=[Environment]::GetFolderPath('Personal');if(-not $x.StartsWith($env:UserProfile)){Remove-Item -LiteralPath (Join-Path $x desktop.ini) -Force -ErrorAction SilentlyContinue}"
@rem Downloads (can't use GetFolderPath here, and PS doesn't have a SHGetKnownFolderPath wrapper either, so we have to use the registry)
powershell -Command "$x=(Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}';if(-not $x.StartsWith($env:UserProfile)){Remove-Item -LiteralPath (Join-Path $x desktop.ini) -Force -ErrorAction SilentlyContinue}"
@rem (My) Pictures
powershell -Command "$x=[Environment]::GetFolderPath('MyPictures');if(-not $x.StartsWith($env:UserProfile)){Remove-Item -LiteralPath (Join-Path $x desktop.ini) -Force -ErrorAction SilentlyContinue}"
@rem (My) Music
powershell -Command "$x=[Environment]::GetFolderPath('MyMusic');if(-not $x.StartsWith($env:UserProfile)){Remove-Item -LiteralPath (Join-Path $x desktop.ini) -Force -ErrorAction SilentlyContinue}"
@rem (My) Video
powershell -Command "$x=[Environment]::GetFolderPath('MyVideo');if(-not $x.StartsWith($env:UserProfile)){Remove-Item -LiteralPath (Join-Path $x desktop.ini) -Force -ErrorAction SilentlyContinue}"
@echo ***** restore fully functional printing dialog
reg add HKCU\Software\Microsoft\Print\UnifiedPrintDialog /v PreferLegacyPrintDialog /t REG_DWORD /d 1 /f /reg:32
reg add HKCU\Software\Microsoft\Print\UnifiedPrintDialog /v PreferLegacyPrintDialog /t REG_DWORD /d 1 /f /reg:64
@echo ***** disable automatic reboot after bluescreen
reg add HKLM\System\CurrentControlSet\Control\CrashControl /v AutoReboot /t REG_DWORD /d 0 /f
@echo ***** give full error information in bluescreens
reg add HKLM\System\CurrentControlSet\Control\CrashControl /v DisplayParameters /t REG_DWORD /d 1 /f
@echo.
@echo ***** disable System Volume Information folder creation on removable media
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows /v DisableRemovableDriveIndexing /t REG_DWORD /d 1 /f
@echo.
@echo ***** disable reboot on automatic updates
@rem cf. https://docs.microsoft.com/en-us/windows/deployment/update/waas-restart
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 4 /f
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f
@echo.
@echo ***** disable Hybrid Shutdown
reg add "HKLM\System\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f
@rem "or manually: Win+X -> Power Options -> Related Settings -> Additional Power Settings"
@rem " -> Choose what the power button does [Sidebar]"
@rem " -> Change settings that are currently unavailable [Shield]"
@rem " -> disable 'Turn on fast startup (recommended)'"
@echo.
@echo ***** uninstall Photos app
@rem Reason: On older Windows 10 versions, it frequently hogged the CPU and disks
@rem in futile attempts to index all images on the PC.
powershell -Command "Get-AppxPackage *photos* | Remove-AppxPackage"
@echo.
@echo ***** removing ModifiableWindowsApps from secondary drive
@rem some checking is done to assure that it's really an empty directory
if not exist "D:\Program Files\ModifiableWindowsApps" goto noMWA
dir /a /b "D:\Program Files\ModifiableWindowsApps\*" | findstr "^" >nul && goto noMWA
takeown /f "D:\Program Files\ModifiableWindowsApps"
takeown /f "D:\Program Files"
icacls "D:\Program Files\ModifiableWindowsApps" /reset
rmdir "D:\Program Files\ModifiableWindowsApps"
rmdir "D:\Program Files"
:noMWA
@echo.
@echo ***** uninstall OneDrive
taskkill /f /im OneDrive.exe
@if errorlevel 1 goto noonedrive
%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
:noonedrive
@echo.
@rem @echo ***** disable Home Groups (only relevant for pre-1803 versions)
@rem sc config HomeGroupProvider start= disabled
@rem sc stop HomeGroupProvider
@rem @echo.
@echo ***** disable (most of) Telemetry
sc config DiagTrack start= disabled
sc stop DiagTrack
@echo.
@echo ***** disable Unfair Commercial Practices Directive driver (requires restart)
sc config UCPD start= disabled
schtasks /change /Disable /TN "\Microsoft\Windows\AppxDeploymentClient\UCPD velocity"
@echo.
@echo ***** disable cursor animations in Office 365
reg add HKCU\Software\Microsoft\Office\16.0\Common\Graphics /v DisableAnimations /t REG_DWORD /d 1 /f
@echo.
@echo.
@echo Will now close all Explorer windows and restart Explorer.
@echo Press ^^C and Y now or close this window to avoid that.
@pause
taskkill /f /im explorer.exe
start explorer.exe
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment