# Windows 11 Tweaks for GPU Benchmark



## W1zzard (Oct 5, 2021)

Updated for 22H2

- Install without Internet
- When it prompts you to go online, press Shift+F10 and type "OOBE\BYPASSNRO" (that's an o not a zero at the end). After the automatic reboot you can install without network
- Install on systems without TPM, UEFI or other requirements: https://www.techpowerup.com/287584/windows-11-tpm-requirement-bypass-it-in-5-minutes
- name the user "TPU" (the user will be deleted at the end of the scripts and you'll be using "Administrator")
- Install VGA driver, from USB, still without network, so Windows Update won't install a graphics driver automatically. Protip: use NVCleanstall
- Run Windows Update, update everything
- No need to update Windows Store apps
- Disable Defender "Tamper protection" via Settings App
- Run the below in admin-rights cmd shell.


```
rem Turn off Windows Startup Recovery Screen
bcdedit /set {current} bootstatuspolicy ignoreallfailures
bcdedit /set {default} recoveryenabled no

rem Create new pagefile. (2nd line indented because wmic will eat a character when pasting)
wmic pagefileset delete
  wmic pagefileset create name=C:\pagefile.sys
  wmic pagefileset set InitialSize=16384,MaximumSize=16384

rem Enable Administrator account
net user Administrator /active:yes

rem Make sure time and date are correct
w32tm /resync /rediscover

rem Disable Error Reporting
reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1 /f

rem Disable automatic TCG/Opal disk locking on supported SSD drives with PSID
reg add HKLM\Software\Policies\Microsoft\Windows\EnhancedStorageDevices /v TCGSecurityActivationDisabled /t REG_DWORD /d 1 /f

rem Control Panel shows Large Icons
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v ForceClassicControlPanel /t REG_DWORD /d 1 /f

rem Disable UAC
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f

rem Disable discovery of LAN devices like printers
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private /f /v AutoSetup /t REG_DWORD /d 0

rem Delete all printers discovered so far
powershell "Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}"

rem Set Ethernet connection to private
powershell Set-NetConnectionProfile -InterfaceAlias Ethernet* -NetworkCategory private

rem Set all "unknown network"s to private by default (such adapters are created by VMWare and VirtualBox for their networking, we don't want the Firewall popup)
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" /v Category /t REG_DWORD /d 1 /f

rem Disable Warnings due to Firewall / Defender being disabled
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\Software\Microsoft\Windows Defender Security Center\Notifications" /v DisableNotifications /t REG_DWORD /d 1 /f

rem Disable Windows Firewall for private network
netsh advfirewall set private state off

rem Workaround for bug that shows Firewall "application blocked" messages, despite Firewall being disabled for private network
netsh firewall set notifications mode=disable profile=standard

rem Disable Windows Defender. For this to work you have to manually disable "Tamper protection"
powershell "if ((Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows Defender\Features').TamperProtection -eq 4) { exit 0; } ; Write-Output 'Windows Defender can not be disabled, Tamper Protection is still active' '' 'Disable Tamper Protection manually, then press OK' | msg /w *"
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Spynet" /v SpyNetReporting /t REG_DWORD /d 0 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Spynet" /v SubmitSamplesConsent /t REG_DWORD /d 2 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableRoutinelyTakingAction /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer" /v SmartScreenEnabled /t REG_SZ /d "Off" /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableRoutinelyTakingAction /t REG_DWORD /d 1 /f
reg delete HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v SecurityHealth /f

rem Remove Windows Defender Scheduled Tasks
for /f "delims=" %f in ('dir /b "%WINDIR%\System32\Tasks\Microsoft\Windows\Windows Defender"') do schtasks /delete /f /tn "Microsoft\Windows\Windows Defender\%f"

rem Disable "Consumer Features" (aka downloading apps from the internet automatically)
reg add HKLM\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f

rem Disable Lock Screen
reg add HKLM\Software\Policies\Microsoft\Windows\Personalization /v NoLockScreen /t REG_DWORD /d 1 /f

rem Remove Logon Wallpaper
reg add HKLM\Software\Policies\Microsoft\Windows\System /v DisableLogonBackgroundImage /t REG_DWORD /d 1 /f

rem Remove Meet Now icon
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v HideSCAMeetNow /t REG_DWORD /d 1 /f

rem Disable One Drive
reg add HKLM\Software\Policies\Microsoft\Windows\OneDrive /v DisableFileSyncNGSC /t REG_DWORD /d 1 /f
start /wait %SystemRoot%\System32\OneDriveSetup.exe /uninstall
rd "%PROGRAMDATA%\Microsoft OneDrive" /Q /S
reg delete "HKEY_USERS\S-1-5-19\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
reg delete "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
reg load HKLM\DEFAULT c:\users\default\ntuser.dat
reg delete HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run /v OneDriveSetup /f
reg unload HKLM\DEFAULT

rem Disable Hibernate
powercfg -h off

rem Turn off sleep mode
powercfg.exe -x -standby-timeout-ac 0

rem Set 4 hours screen blank timeout
powercfg.exe -x -monitor-timeout-ac 240

rem Disable System Restore and delete restore points
powershell disable-computerrestore c:
vssadmin delete shadows /all /quiet

rem Set Timezone
tzutil /s "W. Europe Standard Time"

rem Disable reboot on Bluescreen, and no dump
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v CrashDumpEnabled /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v LogEvent /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v SendAlert /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v AutoReboot /t REG_DWORD /d 0 /f

rem Don't allow Remote Assistance
reg add "HKLM\System\CurrentControlSet\Control\Remote Assistance" /v fAllowToGetHelp /t REG_DWORD /d 0 /f

rem Enable Remote Desktop
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

rem Allow Remote Desktop without password
reg add HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v LimitBlankPasswordUse /t REG_DWORD /d 0 /f

rem Disable Edge Browser preload on startup. We'll never use it anyway, saves memory and startup time
reg add HKLM\Software\Policies\Microsoft\MicrosoftEdge\Main /v AllowPrelaunch /t REG_DWORD /d 0 /f
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v StartupBoostEnabled /t REG_DWORD /d 0 /f

rem Disable Edge Browser (Chromium) first run experience
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v HideFirstRunExperience /t REG_DWORD /d 1 /f

rem Disable Look for App in Store prompt when opening unknown file type
reg add HKLM\Software\Policies\Microsoft\Windows\Explorer /v NoUseStoreOpenWith /t REG_DWORD /d 1 /f

rem Disable Windows Program Compatibility Assistant
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v DisablePCA /t REG_DWORD /d 1 /f

rem Disable Inventory collecting data and sending the info to Microsoft
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v DisableInventory /t REG_DWORD /d 1 /f

rem Disable Application Telemetry
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v AITEnable /t REG_DWORD /d 0 /f

rem Disable Shared Experiences
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\System /v EnableCdp /t REG_DWORD /d 0 /f

rem Remove "Chat" from Taskbar and block automatic Teams installation
rem We need to take ownership of the key first
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://www.techpowerup.com/wizzard/SetACL.exe', '%TEMP%\SetACL.exe');
%TEMP%\SetACL.exe -on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn setowner -ownr "n:Everyone"
%TEMP%\SetACL.exe -on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn ace -ace "n:Everyone;p:full"
del %TEMP%\SetACL.exe

reg add "HKLM\Software\Policies\Microsoft\Windows\Windows Chat" /f /v ChatIcon /t REG_DWORD /d 3
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Communications /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /f /v TaskbarMn /t REG_DWORD /d 0

rem Remove useless Windows components
dism /online /norestart /disable-feature /featurename:Printing-PrintToPDFServices-Features
dism /online /norestart /disable-feature /featurename:Printing-XPSServices-Features
dism /online /norestart /disable-feature /featurename:WorkFolders-Client
dism /online /norestart /disable-feature /featurename:Printing-Foundation-Features
dism /online /norestart /disable-feature /featurename:Printing-Foundation-InternetPrinting-Client
dism /online /norestart /disable-feature /featurename:MSRDC-Infrastructure
dism /online /norestart /disable-feature /featurename:SmbDirect
dism /online /norestart /disable-feature /featurename:MediaPlayback
dism /online /norestart /disable-feature /featurename:WCF-TCP-PortSharing45
dism /online /norestart /disable-feature /featurename:WCF-Services45
dism /online /norestart /disable-feature /featurename:WindowsMediaPlayer

rem Install .NET 3.5 Framework, some older apps and games need this, and you can't install it on demand once Windows Update is disabled
dism /online /norestart /enable-feature /featurename:NetFx3 /all

rem Remove useless optional features
dism /online /norestart /Remove-Capability /CapabilityName:App.StepsRecorder~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:App.Support.QuickAssist~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Browser.InternetExplorer~~~~0.0.11.0
dism /online /norestart /Remove-Capability /CapabilityName:Hello.Face.20134~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.Handwriting~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.Speech~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.TextToSpeech~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:MathRecognizer~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Media.WindowsMediaPlayer~~~~0.0.12.0
dism /online /norestart /Remove-Capability /CapabilityName:Microsoft.Windows.WordPad~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:OneCoreUAP.OneSync~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Print.Management.Console~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Microsoft.Wallpapers.Extended~~~~0.0.1.0

rem Do not remove OCR or Windows will show "Something happened, and we couldn't install a feature" a few hours after cleanup
rem dism /online /norestart /Remove-Capability /CapabilityName:Language.OCR~~~en-US~0.0.1.0

rem Remove a lot of unnecessary apps

powershell "Get-AppXPackage | Where NonRemovable -Match false | Where IsFramework -Match false | Where Name -NotMatch '.*Windows(Store|Notepad|Calculator|Terminal)|NVIDIAControlPanel.*' | Remove-AppXPackage"
powershell "sleep 5"
powershell "Get-AppXProvisionedPackage -online | Where DisplayName -NotMatch '.*Windows(Store|Notepad|Calculator|Terminal)|NVIDIAControlPanel.*' | ForEach-Object { try { Write-Host $_.DisplayName ; Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName  } catch { Write-Host $_ } }"

rem Set Computer name
powershell "Rename-Computer -NewName VGATESTx"

rem Finished
```

*Download and install Firefox silently, make it default browser and adjust settings to remove telemetry and other junk*

```
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US','%TEMP%\ff.exe'); Start-Process %TEMP%\ff.exe /s -NoNewWindow -Wait; Remove-Item %TEMP%\ff.exe"

echo pref("general.config.filename", "firefox.cfg"); > "C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js"
echo pref("general.config.obscure_value", 0); >> "C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js"

echo lockPref("browser.startup.homepage_override.mstone", "ignore"); > "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("browser.messaging-system.whatsNewPanel.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("datareporting.healthreport.uploadEnabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("app.shield.optoutstudies.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("extensions.pocket.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("browser.toolbars.bookmarks.visibility", "never"); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"

rem Looks complicated, but this seems to be the only thing that works, let me know if you know an alternative
Powershell "Start-Process -FilePath 'C:\Program Files\Mozilla Firefox\firefox.exe' -ArgumentList '-setDefaultBrowser' ; Start-Sleep -s 3 ; Start-Process -FilePath 'C:\Program Files\Mozilla Firefox\firefox.exe' -ArgumentList '-setDefaultBrowser' ; Start-Sleep -s 3 ; taskkill /im firefox.exe ; taskkill /im firefox.exe ; taskkill /f /im systemsettings.exe"
```

User-specific (run after logging in as Administrator)

```
rem Install AnyDesk 
rem PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://download.anydesk.com/AnyDesk-CM.exe', '%TEMP%\ad.exe')" && start /wait %TEMP%\ad.exe --remove-first --install "%ProgramFiles%\AnyDesk" --start-with-win --update-manually --create-shortcuts --create-desktop-icon && del %TEMP%\ad.exe

rem Delete TPU user and user profile
net user TPU /delete
powershell "Get-WmiObject Win32_UserProfile | where {$_.localpath -like '*TPU'} | Remove-WmiObject"

rem Disable Windows Game DVR and Game Bar
reg add HKCU\Software\Microsoft\GameBar /v UseNexusForGameBarEnabled /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR /v GameDVR_Enabled /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR /v AppCaptureEnabled /t REG_DWORD /d 0 /f
rem Add workaround for bug that shows "You'll need a new app to open this ms-gamingoverlay" when starting a game
reg add HKEY_CLASSES_ROOT\ms-gamingoverlay /t REG_SZ /d "URL:ms-gamingoverlay" /f

rem Disable Game Mode
reg add HKCU\Software\Microsoft\GameBar /v AutoGameModeEnabled /t REG_DWORD /d 0 /f

rem Disable Web Search
reg add HKCU\Software\Policies\Microsoft\Windows\Explorer /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f

rem Hide Search Box from Task Bar
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Search /v SearchboxTaskbarMode /t REG_DWORD /d 0 /f

rem Hide Task View button
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowTaskViewButton /t REG_DWORD /d 0 /f

rem Windows Explorer Start on This PC instead of Quick Access
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 1 /f

rem Disable frequent/recent items in Explorer Quick Access
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v ShowFrequent /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v ShowRecent /t REG_DWORD /d 0 /f

rem Disable "Let's finish up Windows" nag screen
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement /v ScoobeSystemSettingEnabled /t REG_DWORD /d 0 /f

rem Disable Windows Feedback
reg add HKCU\SOFTWARE\Microsoft\Siuf\Rules /v NumberOfSIUFInPeriod /t REG_DWORD /d 0 /f

rem Show My Computer on Desktop
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t REG_DWORD /d 0 /f

rem Disable Recycle Bin
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoRecycleFiles /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v ConfirmFileDelete /t REG_DWORD /d 1 /f

rem Don't show Recycle Bin on Desktop
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu /v "{645FF040-5081-101B-9F08-00AA002F954E}" /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v "{645FF040-5081-101B-9F08-00AA002F954E}" /t REG_DWORD /d 1 /f

rem Set 24 hour time format
reg add "HKCU\Control Panel\International" /v iFirstDayOfWeek /t REG_SZ /d "0" /f
reg add "HKCU\Control Panel\International" /v sShortDate /t REG_SZ /d "yyyy-MM-dd" /f
reg add "HKCU\Control Panel\International" /v sShortTime /t REG_SZ /d "HH:mm" /f
reg add "HKCU\Control Panel\International" /v sTimeFormat /t REG_SZ /d "HH:mm:ss" /f

rem Turn off Sticky Key when Shift is pressed 5 times
reg add "HKCU\Control Panel\Accessibility\StickyKeys" /v Flags /t REG_SZ /d "506" /f

rem Show file extensions in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t  REG_DWORD /d 0 /f

rem Show Hidden Files in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f

rem Always show more details in file copy dialog
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager /v EnthusiastMode /t REG_DWORD /d 1 /f

rem Set "Do this for all current items" checkbox by default
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager /v ConfirmationCheckBoxDoForAll /t REG_DWORD /d 1 /f

rem Expand left side tree of current folder on Explorer open
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v NavPaneExpandToCurrentFolder /t REG_DWORD /d 1 /f

rem Disable "Let Windows manage my default printer"
reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" /f /v LegacyDefaultPrinterMode /t REG_DWORD /d 1

rem Turn off Wallpaper
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers /v BackgroundType /t REG_DWORD /d 1 /f
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "" /f
reg add "HKCU\Control Panel\Desktop" /v LastUpdated /t REG_DWORD /d 0xffffffff /f
reg add "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "45 125 154" /f

rem Remove 10 second startup delay for application restore
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize /v StartupDelayInMSec /t REG_DWORD /d 0 /f

rem Unpin everything from Taskbar
powershell "(New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items()| foreach { ($_).Verbs() | ?{$_.Name.Replace('&', '') -match 'Unpin from taskbar'} | %{$_.DoIt()}  }"

rem Restore classic context menus / disable "Show more options" menu entry on right-click
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /t REG_SZ /d ""

rem Remove secondary en-US keyboard that gets added when keyboard is set to DE with US region
reg delete "HKCU\Control Panel\International\User Profile\en-US" /v "0409:00000409" /f
reg delete "HKCU\Control Panel\International\User Profile System Backup\en-US" /v "0409:00000409" /f
reg delete "HKCU\Keyboard Layout\Preload" /v "2" /f
reg delete "HKCU\Keyboard Layout\Substitutes" /v "d0010409" /f

rem Remove desktop.ini files from Desktop
del /a C:\Users\Public\Desktop\desktop.ini
del /a C:\Users\Administrator\Desktop\desktop.ini

rem Remove Edge from Desktop (depending on the Edge version this exists in one or the other folder)
del /a "C:\Users\Administrator\Desktop\Microsoft Edge.lnk"
del /a "C:\Users\Public\Desktop\Microsoft Edge.lnk"
```

*Permanently disable Windows Update*
Please note, once disabled, you can only restore MANUAL updates, the (default) automatic behavior is gone

```
rem Stop and delete Windows Update Medic Service (it re-enables Windows Update)
net stop WaasMedicSvc
takeown /f %SYSTEMROOT%\System32\WaaSMedicSvc.dll
cacls %SYSTEMROOT%\System32\WaaSMedicSvc.dll /e /p "Administrator":f
del %SYSTEMROOT%\System32\WaaSMedicSvc.dll

rem Stop and disable Update Orchestrator Service
net stop UsoSvc
takeown /f %SYSTEMROOT%\System32\usosvc.dll
cacls %SYSTEMROOT%\System32\usosvc.dll /e /p "Administrator":f
ren %SYSTEMROOT%\System32\usosvc.dll usosvc.dll.disabled

rem Stop and disable Windows Update Service
net stop wuauserv
takeown /f %SYSTEMROOT%\System32\wuaueng.dll
cacls %SYSTEMROOT%\System32\wuaueng.dll /e /p "Administrator":f
ren %SYSTEMROOT%\System32\wuaueng.dll wuaueng.dll.disabled

rem Remove scheduled tasks
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://www.poweradmin.com/paexec/paexec.exe','%TEMP%\paexec.exe');
for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\WaaSMedic\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic

for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\UpdateOrchestrator\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator

for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\WindowsUpdate\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate

del %TEMP%\paexec.exe
```

*Restore Windows Update (manual updates only)*

```
net stop wuauserv
ren %SYSTEMROOT%\System32\wuaueng.dll.disabled wuaueng.dll
net stop UsoSvc
ren %SYSTEMROOT%\System32\usosvc.dll.disabled usosvc.dll
```

TODO: disable focus asssist


----------



## Halo3Addict (Oct 5, 2021)

Bookmarked  

Quick note: Below didn't work for me


> rem Restore classic context menus / disable "Show more options" menu entry on right-click
> reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /t REG_SZ /d ""



I used this instead:


> reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /t REG_SZ


----------



## W1zzard (Oct 5, 2021)

Halo3Addict said:


> Bookmarked
> 
> Quick note: Below didn't work for me
> 
> ...


Both work for me. Just tested in a VM. Did you sign out/reboot after applying mine?


----------



## Halo3Addict (Oct 6, 2021)

W1zzard said:


> Both work for me. Just tested in a VM. Did you sign out/reboot after applying mine?


I see what my problem was.. I opened the new Windows Terminal app which defaults to powershell with a black background.. kind of confusing

Can confirm the command works in a cmd window. Thanks!


----------



## ThrashZone (Oct 23, 2021)

Hi,
That went okay
Redid win-10 off the other script mbam 4.4.9 had a hold on tamper protection and wouldn't let go lol

Terminal seems a waste.


----------



## W1zzard (Oct 23, 2021)

ThrashZone said:


> tamper protection


press windows key, type tamper, click first option, go down a few options and turn it off manually. that's the only way, otherwise "tamper protection" would be useless if you could disable it from script


----------



## Ferrum Master (Oct 23, 2021)

Any feedback also using Manage_Speculative_Execution_Protection_Settings_v3.3 I usually use especially for older Intel platforms?

Yay or nay?


```
@echo off
:: Author: Hendrik Vermaak
:: Created: 17 August 2018. Updated: 15 March 2020.

set "tle=Manage Speculative Execution Protection Settings Script"
set sv=v3.3
title %tle% %sv%

:: Start Command Prompt Maximised
if not "%1" == "max" start /MAX cmd /c %0 max & exit/b

:: Check for Administrative Permissions
reg query "HKU\S-1-5-19\Environment" >nul 2>&1
If Not %ERRORLEVEL% EQU 0 (
echo.
echo  Launching %tle% . . .
timeout /t 3 >nul
powershell.exe -command "Start-Process -FilePath '%0' -Verb runAs"
exit )
pushd "%CD%"
CD /D "%~dp0"

::Set Colors
set ESC=
set br=%ESC%[91m
set bg=%ESC%[92m
set bw=%ESC%[37m

:: Check if Registry Settings Backup File Exists.
if not exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ( goto regbnf ) >nul 2>&1
goto regbf
:regbnf
call :regbackup
:regbf

:: Get Operating System Info
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v buildlabex | find /i "AMD64" >nul
if %errorlevel% equ 0 (set arch=x64) else (set arch=x86)
for /f "tokens=3* delims= " %%G in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v productname') DO (set winv=%%G %%H)
echo %winv% | find /i "Windows 10" >nul
if %errorlevel% equ 0 (set w10=1&for /f "tokens=3" %%G in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR') DO (set /a UBR=%%G))
if defined w10 (for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v buildlabex') DO (set "win=%winv% %arch%, Build %%G.%UBR% {%%I %%J}")
) else (
for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v buildlabex') DO (set "wini=%winv% %arch% Build %%G.%%H {%%I %%J}")
)
set "wini=OS: %lb%%win%"

:: Get Motherboard Info
for /f "tokens=3* delims= " %%i in ('reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS /v BaseBoardManufacturer') DO (set mbm=%%i %%j)
for /f "tokens=3* delims= " %%i in ('reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS /v BaseBoardProduct') DO (set mbp=%%i %%j)
for /f "tokens=3* delims= " %%i in ('reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS /v SystemVersion') DO (set mbv=%%i)
set "mb=Motherboard: %mbm% %mbp% %mbv%"

:: Get BIOS Version
for /f "tokens=3* delims= " %%i in ('reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS /v BIOSVersion') DO (set bsv=%%i)
for /f "tokens=3* delims= " %%i in ('reg query HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS /v BIOSReleaseDate') DO (set brd=%%i)
set "bv=BIOS Version: %bsv% %brd%"

:: Check if Hyper-V is Installed
sc query "HvHost" | find "RUNNING" >nul
if "%ERRORLEVEL%"=="0" ( goto yeshv )
sc query "vmcompute" | find "RUNNING" >nul
if "%ERRORLEVEL%"=="0" ( goto yeshv )
sc query "vmms" | find "RUNNING" >nul
if "%ERRORLEVEL%"=="0" ( goto yeshv ) else ( goto nohv )
:yeshv
set skiphv1=skiphvno1
set skiphv2=skiphvno2
set skiphv3=skiphvno3
set "hyperv=Hyper-V: Enabled"
set "host1=* "If this is a Hyper-V host and the firmware updates have been applied: Fully shut down all"
set "host2=  Virtual Machines. This enables the firmware-related mitigation to be applied on the host"
set "host3=  before the VMs are started. Therefore, the VMs are also updated when they're restarted.""
set time=2
goto cht
:nohv
set skiphv1=skiphvyes1
set skiphv2=skiphvyes2
set skiphv3=skiphvyes3
set time=0

:cht
echo.
echo  Gathering System Information...

:: Check Hyper-Threading
for /f "tokens=* skip=3" %%i in ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object Name"') DO (set cpu=%%i)
echo %cpu% | find /i "Intel" >nul
if %ErrorLevel%==0 ( goto yesi ) else ( goto csmt )
:yesi
for /f "tokens=* skip=3" %%G IN ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object NumberOfCores"') DO if not defined core set "core=%%G"
for /f "tokens=* skip=3" %%G IN ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object NumberOfLogicalProcessors"') DO if not defined lproc set "lproc=%%G"
if not %core% == %lproc% ( set "hts=Hyper-Threading: Enabled" ) else ( set "hts=Hyper-Threading: Disabled/Not Supported" )
goto microcode

:csmt
:: Check SMT
for /f "tokens=* skip=3" %%i in ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object Name"') DO (set cpu=%%i)
echo %cpu% | find /i "AMD" >nul
if %ErrorLevel%==0 ( goto yesa ) else ( goto microcode )
:yesa
for /f "tokens=* skip=3" %%G IN ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object NumberOfCores"') DO if not defined core set "core=%%G"
for /f "tokens=* skip=3" %%G IN ('powershell -command "Get-CimInstance -ClassName Win32_Processor | Select-Object NumberOfLogicalProcessors"') DO if not defined lproc set "lproc=%%G"
if not %core% == %lproc% ( set "hts=SMT: Enabled" ) else ( set "hts=SMT: Disabled/Not Supported" )

:MicroCode
set "cpun=CPU: %cpu%"
for /f "tokens=4* delims= " %%G in ('reg query "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0" /v "Update Revision" ^| findstr "."') DO (set UC=%%G)
set "mc=MicroCode: %UC%"

:: Get Current Execution Policy Variable
for /f "tokens=*" %%a in ('powershell -command "get-executionpolicy"') DO set variable=%%a
if exist "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" (
goto mainmenu ) else ( goto installmodule ) >nul 2>&1

:installmodule
cls
echo. %bg%%sv%
echo %bw%=============================================================================================================
echo                           %tle%
echo %bw%=============================================================================================================
echo.
echo %br%* SpeculationControl Module Package not Found!
echo.
echo %bw%=============================================================================================================
echo.
timeout /t 1 /nobreak >nul
echo  Options:
echo.
echo  [1] SpeculationControl Module Overview and Usage Information.(Weblink)
echo.
echo  [2] Download and Install the SpeculationControl Module Package now? Internet Connection Required.
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit the script.
echo.
echo.
set "m1="
set /P "m1=Type an Option Number and Press Enter: "
(
IF "%m1%"=="1" goto overviewinfo
IF "%m1%"=="2" goto autoinstall
IF "%m1%"=="3" goto mainmenu
IF "%m1%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 1 /nobreak >nul
goto installmodule

:overviewinfo
start "" "https://github.com/Microsoft/SpeculationControl"
goto installmodule

:autoinstall
cls
echo. %bg%%sv%
echo %bw%=============================================================================================================
echo                              Installing SpeculationControl Module Package
echo %bw%=============================================================================================================
echo.
PowerShell.exe -Command "Install-Module -Name SpeculationControl -force"
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
timeout /t 5 /nobreak >nul

:mainmenu
cls
:: Check if a system restart is required.
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending >nul 2>&1
if "%ErrorLevel%"=="0" ( goto pending ) else ( goto nopending )
:pending
set "RPRC=A Reboot is Pending. Please Restart the Computer to Apply the Registry Changes."
set "RR=%bg%%RPRC%"
set rrskip1=rrskipno1
set rrskip2=rrskipno2
set rrskip3=rrskipno3
set "exit=Exit without Restarting."
set skiprpmb=noskipm13
set skiprpma=noskipm11
set skiprpm=noskipm1
goto exitwr
:nopending
set rrskip1=rrskipyes1
set rrskip2=rrskipyes2
set rrskip3=rrskipyes3
set "exit=Exit the Script."
set skiprpmb=yesskipm23
set skiprpma=yesskipm21
set skiprpm=yesskipm2
:exitwr

:option2a
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride >nul 2>&1
if "%ErrorLevel%"=="0" ( goto option2b ) else ( goto nf2a )
:nf2a
set "[2]=[2]"
set mo2=%br%This Mitigation Option is not Enabled
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v Featuresettings | Find "0x0" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao2a ) else ( goto option3 )
:ao2a
set "active= %bg%[2]"
set "active_= [2]"
set [2]=%bg%[2]%bw%
set mo2=%bg%This Mitigation Option is Enabled
goto option3

:option2b
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f23b ) else ( goto nf23b )
:f23b
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x0" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao2b ) else ( goto nf23b )
:ao2b
set "active= %bg%[2]"
set "active_= [2]"
set [2]=%bg%[2]%bw%
set mo2=%bg%This Mitigation Option is Enabled
goto option3
:nf23b
set "[2]=[2]"
set mo2=%br%This Mitigation Option is not Enabled

:option3
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f33 ) else ( goto nf33 )
:f33
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x1" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao3 ) else ( goto nf33 )
:ao3
set "active= %bg%[3]"
set "active_= [3]"
set [3]=%bg%[3]%bw%
set "mo3=%br%Mitigations for Spectre Variant 2 are Disabled"
goto option4
:nf33
set "[3]=[3]"
set mo3=%br%This Mitigation Option is not Enabled

:option4
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f43 ) else ( goto nf43 )
:f43
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x40" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao4 ) else ( goto nf43 )
:ao4
set "active= %bg%[4]"
set "active_= [4]"
set [4]=%bg%[4]%bw%
set mo4=%bg%This Mitigation Option is Enabled
goto option5
:nf43
set "[4]=[4]"
set mo4=%br%This Mitigation Option is not Enabled

:option5
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f53 ) else ( goto nf53 )
:f53
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x8" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao5 ) else ( goto nf53 )
:ao5
set "active= %bg%[5]"
set "active_= [5]"
set [5]=%bg%[5]%bw%
set mo5=%bg%This Mitigation Option is Enabled
goto option6
:nf53
set "[5]=[5]"
set mo5=%br%This Mitigation Option is not Enabled

:option6
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f63 ) else ( goto nf63 )
:f63
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x48" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f648 ) else ( goto nf63 )
:f648
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption | Find "0x6" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f6 ) else ( goto nf63 )
:f6
set "active= %bg%[6]"
set "active_= [6]"
set [6]=%bg%[6]%bw%
set mo6=%bg%This Mitigation Option is Enabled
goto option7
:nf63
set "[6]=[6]"
set mo6=%br%This Mitigation Option is not Enabled

:option7
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f73 ) else ( goto nf73 )
:f73
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x48" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f748 ) else ( goto nf73 )
:f748
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption | Find "0x7" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f7 ) else ( goto nf73 )
:f7
set "active= %bg%[7]"
set "active_= [7]"
set [7]=%bg%[7]%bw%
set mo7=%bg%This Mitigation Option is Enabled
goto option8
:nf73
set "[7]=[7]"
set mo7=%br%This Mitigation Option is not Enabled

:option8
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f83 ) else ( goto nf83 )
:f83
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x2048" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao8 ) else ( goto nf83 )
:ao8
set "active= %bg%[8]"
set "active_= [8]"
set [8]=%bg%[8]%bw%
set mo8=%bg%This Mitigation Option is Enabled
goto option9a
:nf83
set "[8]=[8]"
set mo8=%br%This Mitigation Option is not Enabled

:option9a
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride >nul 2>&1
if "%ErrorLevel%"=="0" ( goto option9b ) else ( goto nf9a )
:nf9a
set "[9]=[9]"
set mo9=Active Mitigation Option:%active%
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v Featuresettings | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao9a ) else ( goto menu )
:ao9a
set "active= %bg%[9]"
set "active_= [9]"
set [9]=%bg%[9]%bw%
set "mo9=%br%All Mitigations are Disabled"
goto menu

:option9b
cls
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto f93 ) else ( goto nf93 )
:f93
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride | Find "0x3" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto ao9b ) else ( goto nf93 )
:ao9b
set "active= %bg%[9]"
set "active_= [9]"
set [9]=%bg%[9]%bw%
set "mo9=%br%All Mitigations are Disabled"
goto menu
:nf93
set "[9]=[9]"
set mo9=Active Mitigation Option:%active%

:menu
cls
echo. %bg%%sv%
echo %bw%=============================================================================================================
echo                                Speculative Execution Protection Settings Menu
echo %bw%=============================================================================================================
echo. Active Mitigation Option:%active%
echo %bw%=============================================================================================================
echo. %mb%
echo %bw%=============================================================================================================
echo. %bv%
echo %bw%=============================================================================================================
echo. %mc%
echo %bw%=============================================================================================================
echo. %cpun%
echo %bw%=============================================================================================================
echo. %hts% (%core: =% Cores / %lproc: =% Threads)
echo %bw%=============================================================================================================
echo. %wini%
echo %bw%=============================================================================================================
goto %skiphv1%
:skiphvno1
echo. %hyperv%
echo %bw%=============================================================================================================
:skiphvyes1
goto %rrskip1%
:rrskipno1
echo. %RR%
echo %bw%=============================================================================================================
:rrskipyes1
echo.
echo  Options:
echo.
echo   [1] Check Speculative Execution Protection Status.
echo.
echo   %[2]% Enable Mitigations for Spectre variant 2 and Meltdown.(Default Mitigations)
echo.
echo   %[3]% Disable Mitigations for Spectre variant 2.
echo.
echo   %[4]% AMD and ARM Processors Only: Enable Full Mitigation for Spectre variant 2.
echo.
echo   %[5]% Enable Mitigations for Speculative Store Bypass, Spectre variant 2 and Meltdown.
echo.
echo   %[6]% AMD Processors Only: Enable Full Mitigation for Spectre variant 2 and Speculative Store Bypass.
echo.
echo   %[7]% Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous
echo       Abort vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants,
echo       including Speculative Store Bypass Disable as well as L1 Terminal Fault without Disabling Hyper-Threading.
echo.
echo   %[8]% Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous
echo       Abort vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants,
echo       including Speculative Store Bypass Disable as well as L1 Terminal Fault with Hyper-Threading Disabled.
echo.
echo   %[9]% Disable all Speculative Execution Protection Mitigations.
echo.
echo  [10] Reset Registry Settings Menu.
echo.
echo  [11] SpeculationControl Module Installation Menu.
echo.
echo  [12] More Information and References.(Weblinks)
goto %skiprpma%
:noskipm11
echo.
echo  [13] Restart Options Menu.
:yesskipm21
echo.
echo.
echo  [00] %exit%
echo.
echo.
set "m2="
set /P "m2=Type an Option Number and Press Enter: "
(
IF "%m2%"=="1" goto menu01
IF "%m2%"=="2" goto menu02
IF "%m2%"=="3" goto menu03
IF "%m2%"=="4" goto menu04
IF "%m2%"=="5" goto menu05
IF "%m2%"=="6" goto menu06
IF "%m2%"=="7" goto menu07
IF "%m2%"=="8" goto menu08
IF "%m2%"=="9" goto menu09
IF "%m2%"=="10" goto menu10
IF "%m2%"=="11" goto menu11
IF "%m2%"=="12" goto menu12
goto %skiprpmb%
:noskipm13
IF "%m2%"=="13" goto menu13
:yesskipm23
IF "%m2%"=="00" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu

:menu01
cls
echo. %sv%
echo %bw%=============================================================================================================
echo.                                Speculative Execution Protection Status
echo %bw%=============================================================================================================
echo. Active Mitigation Option:%active%
echo %bw%=============================================================================================================
echo. %mb%
echo %bw%=============================================================================================================
echo. %bv%
echo %bw%=============================================================================================================
echo. %mc%
echo %bw%=============================================================================================================
echo. %cpun%
echo %bw%=============================================================================================================
echo. %hts% (%core: =% Cores / %lproc: =% Threads)
echo %bw%=============================================================================================================
echo. %wini%
echo %bw%=============================================================================================================
goto %skiphv2%
:skiphvno2
echo. %hyperv%
echo %bw%=============================================================================================================
:skiphvyes2
goto %rrskip2%
:rrskipno2
echo. %RR%
echo %bw%=============================================================================================================
:rrskipyes2
call :showcurrent
call :showbackup
echo.
PowerShell.exe -Command "Set-ExecutionPolicy RemoteSigned -Scope Currentuser" >nul
PowerShell.exe -Command "Get-SpeculationControlsettings"
for /f "tokens=1,2,3,4* delims=/, " %%a in ('date /t') DO set yyyymmdd=%%c-%%b-%%a
for /f "tokens=1-4 delims=:., " %%a in ('time /t') DO set hhmm=%%a%%b%%c
set "textfile=Speculative_Execution_Protection_Status_%yyyymmdd%_%hhmm%.txt"
echo. %sv% > "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo.                                Speculative Execution Protection Status >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. Active Mitigation Option:%active_% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %mb% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %bv% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %mc% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %cpun% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %hts%  (%core: =% Cores / %lproc: =% Threads) >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. %wini% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
goto %skiphv3%
:skiphvno3
echo. %hyperv% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
:skiphvyes3
goto %rrskip3%
:rrskipno3
echo. %RPRC% >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
:rrskipyes3
echo  Current Registry Settings: >> "%CD%\%textfile%"
set linec_=0
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec_=%linec_%+1&goto fsnf10rsrm1b ) else ( goto fsf10rsrm1b )
:fsf10rsrm1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" ^| find "REG_DWORD"') DO set /a fs10rsrm1b=%%H > nul
echo  FeatureSettings %fs10rsrm1b% >> "%CD%\%textfile%"
:fsnf10rsrm1b
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec_=%linec_%+1&goto fsonf10rsrm1b ) else ( goto fsof10rsrm1b )
:fsof10rsrm1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" ^| find "REG_DWORD"') DO set /a fso10rsrm1b=%%H > nul
echo  FeatureSettingsOverride %fso10rsrm1b% >> "%CD%\%textfile%"
:fsonf10rsrm1b
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec_=%linec_%+1&goto fsomnf10rsrm1b ) else ( goto fsomf10rsrm1b )
:fsomf10rsrm1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" ^| find "REG_DWORD"') DO set /a fsom10rsrm1b=%%H > nul
echo  FeatureSettingsOverrideMask %fsom10rsrm1b% >> "%CD%\%textfile%"
:fsomnf10rsrm1b
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec_=%linec_%+1&goto mvvmnf10rsrm1b ) else ( goto mvvmf10rsrm1b )
:mvvmf10rsrm1b
for /f "tokens=2* skip=2" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations"') DO (set "mvvm10rsrm1b=%%b") > nul
echo  MinVmVersionForCpuBasedMitigations %mvvm10rsrm1b% >> "%CD%\%textfile%"
:mvvmnf10rsrm1b
if "%linec%"=="5" echo  None >> "%CD%\%textfile%"
echo ============================================================================================================= >> "%CD%\%textfile%"
if exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" (
goto showbackup1m ) else ( goto bnfm ) >nul 2>&1
:bnfm
echo  Backup Registry Settings: >> "%CD%\%textfile%"
echo  Backup File not Found! >> "%CD%\%textfile%"
goto nextab1sb
:showbackup1m
echo  Backup Registry Settings: >> "%CD%\%textfile%"
set linet=0
find /c "1 FeatureSettings" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 1 set /a linet=%linet%+1
find /c "2 FeatureSettingsOverride" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 1 set /a linet=%linet%+1
find /c "3 FeatureSettingsOverrideMask" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 1 set /a linet=%linet%+1
find /c "4 MinVmVersionForCpuBasedMitigations" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 1 set /a linet=%linet%+1
if "%linet%"=="4" goto :nonet
set line1=0
set line0=1
set loop=0
for /f "usebackq" %%A in (`TYPE "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| find /v /c "" `) DO set line1=%%A
:loopab1sb
set /a loop=%loop%+1
for /f "tokens=1,2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "type=%%b")
for /f "tokens=2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "data=%%b")
echo. %type% %data% >> "%CD%\%textfile%"
if "%line0%"=="%line1%" goto skipnonet
set /a "line0"="%line0%+1"
goto loopab1sb
:nonet
echo  None >> "%CD%\%textfile%"
:skipnonet
echo ============================================================================================================= >> "%CD%\%textfile%"
echo. >> "%CD%\%textfile%"
PowerShell.exe -Command "Get-SpeculationControlsettings" >> "%CD%\%textfile%"
PowerShell.exe -Command "Set-ExecutionPolicy %variable% -Scope Currentuser" >nul
echo  Copy of the results saved to the current directory of this script.
timeout /t 1 /nobreak >nul
echo.
echo  Please Press any Key to Go to the Main Menu...
pause >nul
goto mainmenu

:menu02
cls
echo.
echo %bw%=============================================================================================================
echo                    Enable Mitigations for Spectre variant 2 and Meltdown.(Default Mitigations)
echo %bw%=============================================================================================================
echo. %mo2%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable the Default Mitigations now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m3="
set /P "m3=Type an Option Number and Press Enter: "
(
IF "%m3%"=="1" goto menu2a
IF "%m3%"=="2" goto mainmenu
IF "%m3%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu02

:menu2a
cls
echo.
echo %bw%=============================================================================================================
echo                    Enable Mitigations for Spectre variant 2 and Meltdown.(Default Mitigations)
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 0 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 2 /f>nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu2b
cls
echo.
echo %bw%=============================================================================================================
echo                    Enable Mitigations for Spectre variant 2 and Meltdown.(Default Mitigations)
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Default Mitigations have been Enabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m4="
set /P "m4=Type an Option Number and Press Enter: "
(
IF "%m4%"=="1" goto restart
IF "%m4%"=="2" goto restart2
IF "%m4%"=="3" goto mainmenu
IF "%m4%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu2b

:menu03
cls
echo.
echo %bw%=============================================================================================================
echo                                  Disable Mitigations for Spectre variant 2
echo %bw%=============================================================================================================
echo. %mo3%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Disable the Mitigations now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m5="
set /P "m5=Type an Option Number and Press Enter: "
(
IF "%m5%"=="1" goto menu3a
IF "%m5%"=="2" goto mainmenu
IF "%m5%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu03

:menu3a
cls
echo.
echo %bw%=============================================================================================================
echo                                  Disable Mitigations for Spectre variant 2
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 3 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu3b
cls
echo.
echo %bw%=============================================================================================================
echo                                  Disable Mitigations for Spectre variant 2
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Mitigations have been Disabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m6="
set /P "m6=Type an Option Number and Press Enter: "
(
IF "%m6%"=="1" goto restart
IF "%m6%"=="2" goto restart2
IF "%m6%"=="3" goto mainmenu
IF "%m6%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu3b

:menu04
cls
echo.
echo %bw%=============================================================================================================
echo                   AMD and ARM Processors Only: Enable Full Mitigation for Spectre variant 2
echo %bw%=============================================================================================================
echo. %mo4%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable Full Mitigation now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m7="
set /P "m7=Type an Option Number and Press Enter: "
(
IF "%m7%"=="1" goto menu4a
IF "%m7%"=="2" goto mainmenu
IF "%m7%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu04

:menu4a
cls
echo.
echo %bw%=============================================================================================================
echo                   AMD and ARM Processors Only: Enable Full Mitigation for Spectre variant 2
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 64 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 4 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul
echo.

:menu4b
cls
echo.
echo %bw%=============================================================================================================
echo                   AMD and ARM Processors Only: Enable Full Mitigation for Spectre variant 2
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Full Mitigation has been Enabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m8="
set /P "m8=Type an Option Number and Press Enter: "
(
IF "%m8%"=="1" goto restart
IF "%m8%"=="2" goto restart2
IF "%m8%"=="3" goto mainmenu
IF "%m8%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu4b

:menu05
cls
echo.
echo %bw%=============================================================================================================
echo               Enable Mitigations for Speculative Store Bypass, Spectre variant 2 and Meltdown
echo %bw%=============================================================================================================
echo. %mo5%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable the Mitigations now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m9="
set /P "m9=Type an Option Number and Press Enter: "
(
IF "%m9%"=="1" goto menu5a
IF "%m9%"=="2" goto mainmenu
IF "%m9%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu05

:menu5a
cls
echo.
echo %bw%=============================================================================================================
echo               Enable Mitigations for Speculative Store Bypass, Spectre variant 2 and Meltdown
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 8 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 5 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu5b
cls
echo.
echo %bw%=============================================================================================================
echo               Enable Mitigations for Speculative Store Bypass, Spectre variant 2 and Meltdown
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Mitigations have been Enabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m10="
set /P "m10=Type an Option Number and Press Enter: "
(
IF "%m10%"=="1" goto restart
IF "%m10%"=="2" goto restart2
IF "%m10%"=="3" goto mainmenu
IF "%m10%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu5b

:menu06
cls
echo.
echo %bw%=============================================================================================================
echo        AMD Processors Only: Enable Full Mitigation for Spectre variant 2 and Speculative Store Bypass
echo %bw%=============================================================================================================
echo. %mo6%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable Full Mitigation now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m11="
set /P "m11=Type an Option Number and Press Enter: "
(
IF "%m11%"=="1" goto menu6a
IF "%m11%"=="2" goto mainmenu
IF "%m11%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu06

:menu6a
cls
echo.
echo %bw%=============================================================================================================
echo        AMD Processors Only: Enable Full Mitigation for Spectre variant 2 and Speculative Store Bypass
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 72 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 6 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu6b
cls
echo.
echo %bw%=============================================================================================================
echo        AMD Processors Only: Enable Full Mitigation for Spectre variant 2 and Speculative Store Bypass
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Full Mitigation has been Enabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m12="
set /P "m12=Type an Option Number and Press Enter: "
(
IF "%m12%"=="1" goto restart
IF "%m12%"=="2" goto restart2
IF "%m12%"=="3" goto mainmenu
IF "%m12%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu6b

:menu07
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault without disabling Hyper-Threading.
echo %bw%=============================================================================================================
echo. %mo7%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable the Mitigations now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m13="
set /P "m13=Type an Option Number and Press Enter: "
(
IF "%m13%"=="1" goto menu7a
IF "%m13%"=="2" goto mainmenu
IF "%m13%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu07

:menu7a
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault without disabling Hyper-Threading.
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
sc query "vmms" | find "RUNNING" >nul
if "%ERRORLEVEL%"=="0" ( goto yeshv7 ) else ( goto nohv7 )
:yeshv7
set skip=noskip7
goto noskip27
:nohv7
set skip=skip37
:noskip27
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 72 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v MinVmVersionForCpuBasedMitigations /t REG_SZ /d "1.0" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 7 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu7b
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault without disabling Hyper-Threading.
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Mitigations have been Enabled.
echo.
goto %skip%
:noskip7
echo.%host1%
echo. %host2%
echo. %host3%
timeout /t %time% /nobreak >nul
echo.
:skip37
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m14="
set /P "m14=Type an Option Number and Press Enter: "
(
IF "%m14%"=="1" goto restart
IF "%m14%"=="2" goto restart2
IF "%m14%"=="3" goto mainmenu
IF "%m14%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu7b

:menu08
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort 
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault with Hyper-Threading Disabled.
echo %bw%=============================================================================================================
echo. %mo8%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Enable Full Mitigation now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m15="
set /P "m15=Type an Option Number and Press Enter: "
(
IF "%m15%"=="1" goto menu8a
IF "%m15%"=="2" goto mainmenu
IF "%m15%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu08

:menu8a
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort 
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault with Hyper-Threading Disabled.
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
sc query "vmms" | find "RUNNING" >nul
if "%ERRORLEVEL%"=="0" ( goto yeshv8 ) else ( goto nohv8 )
:yeshv8
set skip=noskip8
goto noskip28
:nohv8
set skip=skip38
:noskip28
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 8264 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v MinVmVersionForCpuBasedMitigations /t REG_SZ /d "1.0" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 8 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu8b
cls
echo.
echo %bw%=============================================================================================================
echo    Enable Mitigations for Intel(R) Transactional Synchronization Extensions Transaction Asynchronous Abort 
echo    vulnerability and Microarchitectural Data Sampling along with Spectre and Meltdown variants, including
echo    Speculative Store Bypass Disable as well as L1 Terminal Fault with Hyper-Threading Disabled.
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * Full Mitigation has been Enabled.
echo.
goto %skip%
:noskip8
echo.%host1%
echo. %host2%
echo. %host3%
timeout /t %time% /nobreak >nul
echo.
:skip38
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m16="
set /P "m16=Type an Option Number and Press Enter: "
(
IF "%m16%"=="1" goto restart
IF "%m16%"=="2" goto restart2
IF "%m16%"=="3" goto mainmenu
IF "%m16%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu8b

:menu09
cls
echo.
echo %bw%=============================================================================================================
echo                           Disable all Speculative Execution Protection Mitigations
echo %bw%=============================================================================================================
echo. %mo9%
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Disable all Speculative Execution Protection Mitigations now?
echo.
echo  [2] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m17="
set /P "m17=Type an Option Number and Press Enter: "
(
IF "%m17%"=="1" goto menu9a
IF "%m17%"=="2" goto mainmenu
IF "%m17%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu09

:menu9a
cls
echo.
echo %bw%=============================================================================================================
echo                           Disable all Speculative Execution Protection Mitigations
echo %bw%=============================================================================================================
call :showcurrent
echo.
timeout /t 1 /nobreak >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverride /t REG_DWORD /d 3 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\Session Manager\Memory Management" /v FeaturesettingsOverrideMask /t REG_DWORD /d 3 /f
call :minvmq
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /t REG_DWORD /d 9 /f >nul 2>&1
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 2 /nobreak >nul

:menu9b
cls
echo.
echo %bw%=============================================================================================================
echo                           Disable all Speculative Execution Protection Mitigations
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * All Speculative Execution Protection Mitigations have been Disabled.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m18="
set /P "m18=Type an Option Number and Press Enter: "
(
IF "%m18%"=="1" goto restart
IF "%m18%"=="2" goto restart2
IF "%m18%"=="3" goto mainmenu
IF "%m18%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu9b

:menu10
if exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" (
set "rsreg=Restore Speculative Execution Protection Registry Settings from Backup?"
 ) else (
set "rsreg=Backup Current Speculative Execution Protection Registry Settings?" ) >nul 2>&1
cls
echo.
echo %bw%=============================================================================================================
echo                                          Reset Registry Settings Menu
echo %bw%=============================================================================================================
call :showcurrent
call :showbackup
echo.
echo  Options:
echo.
echo  [1] Remove all non-default Speculative Execution Protection Registry Settings?
echo.
echo  [2] Reset all Speculative Execution Protection Registry Settings?
echo.
echo  [3] %rsreg%
echo.
echo  [4] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m19="
set /P "m19=Type an Option Number and Press Enter: "
(
IF "%m19%"=="1" goto remove
IF "%m19%"=="2" goto reset
IF "%m19%"=="3" goto restore
IF "%m19%"=="4" goto mainmenu
IF "%m19%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu10

:remove
cls
echo.
echo %bw%=============================================================================================================
echo                    Remove non-default Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Remove all non-default Speculative Execution Protection Mitigation Registry Settings now?
echo.
echo  [2] Go back to the Reset Speculative Execution Protection Mitigation Registry Settings Menu.
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m20="
set /P "m20=Type an Option Number and Press Enter: "
(
IF "%m20%"=="1" goto remove1a
IF "%m20%"=="2" goto menu10
IF "%m20%"=="3" goto mainmenu
IF "%m20%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto remove

:remove1a
cls
echo.
echo %bw%=============================================================================================================
echo                    Remove non-default Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto frfso ) else ( goto nfrfso )
:frfso
echo y | reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" /f
:nfrfso
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto frfsom ) else ( goto nfrfsom )
:frfsom
echo y | reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" /f
:nfrfsom
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto fvmbm ) else ( goto nfvmbm )
:fvmbm
echo y | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" /f
:nfvmbm
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v "ActiveMitigationOption" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto famo ) else ( goto nfamo )
:famo
echo y | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v ActiveMitigationOption /f
:nfamo
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 1 /nobreak >nul

:remove1b
cls
echo.
echo %bw%=============================================================================================================
echo                    Remove non-default Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * All non-default Speculative Execution Protection Registry Settings have been Removed.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Logon?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m21="
set /P "m21=Type an Option Number and Press Enter: "
(
IF "%m21%"=="1" goto restart
IF "%m21%"=="2" goto restart2
IF "%m21%"=="3" goto mainmenu
IF "%m21%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto remove1b

:reset
cls
echo.
echo %bw%=============================================================================================================
echo                         Reset all Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo  Options:
echo.
echo  [1] Reset all Speculative Execution Protection Registry Settings now?
echo.
echo  [2] Go back to the Reset Speculative Execution Protection Registry Settings Menu.
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m22="
set /P "m22=Type an Option Number and Press Enter: "
(
IF "%m22%"=="1" goto reset1a
IF "%m22%"=="2" goto menu10
IF "%m22%"=="3" goto mainmenu
IF "%m22%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto reset

:reset1a
cls
echo.
echo %bw%=============================================================================================================
echo                         Reset all Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto frfsrs ) else ( goto nfrfsrs )
:frfsrs
echo y | reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" /f
:nfrfsrs
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto frfsors ) else ( goto nfrfsors )
:frfsors
echo y | reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" /f
:nfrfsors
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto frfsomrs ) else ( goto nfrfsomrs )
:frfsomrs
echo y | reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" /f
:nfrfsomrs
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto fvmbmrs ) else ( goto nfvmbmrs )
:fvmbmrs
echo y | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" /f
:nfvmbmrs
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mmenu" /v "ActiveMitigationOption" >nul 2>&1
if "%ErrorLevel%"=="0" ( goto famors ) else ( goto nfamors )
:famors
set "active="
:nfamors
echo y | reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending /t REG_SZ /d "%tle%" >nul 2>&1
timeout /t 1 /nobreak >nul

:reset1b
cls
echo.
echo %bw%=============================================================================================================
echo                         Reset all Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
call :showcurrent
echo.
echo * All Speculative Execution Protection Registry Settings have been Reset.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Logon?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m23="
set /P "m23=Type an Option Number and Press Enter: "
(
IF "%m23%"=="1" goto restart
IF "%m23%"=="2" goto restart2
IF "%m23%"=="3" goto mainmenu
IF "%m23%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto reset1b

:restore
if exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" (
goto backupf ) else ( goto backupnf ) >nul 2>&1
:backupf
cls
echo.
echo %bw%=============================================================================================================
echo                      Restore Speculative Execution Protection Registry Settings from Backup
echo %bw%=============================================================================================================
call :showcurrent
call :showbackup
echo.
echo  Options:
echo.
echo  [1] Restore the Speculative Execution Protection Registry Settings from Backup now?
echo.
echo  [2] Go back to the Reset Speculative Execution Protection Registry Settings Menu.
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m24="
set /P "m24=Type an Option Number and Press Enter: "
(
IF "%m24%"=="1" goto restore1a
IF "%m24%"=="2" goto menu10
IF "%m24%"=="3" goto mainmenu
IF "%m24%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto restore

:restore1a
cls
echo.
echo %bw%=============================================================================================================
echo                      Restore Speculative Execution Protection Registry Settings from Backup
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
find /c "1 FeatureSettings" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto found1
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" /f  >nul 2>&1
:found1
find /c "FeatureSettingsOverride" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto found2
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" /f >nul 2>&1
:found2
find /c "FeatureSettingsOverrideMask" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto found3
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" /f >nul 2>&1
:found3
find /c "MinVmVersionForCpuBasedMitigations" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto found4
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" /f >nul 2>&1
:found4
set line1=0
set line0=1
set loop=0
echo.
for /f "usebackq" %%A in (`TYPE "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| find /v /c "" `) DO set line1=%%A
echo.
:loopa
set /a loop=%loop%+1
for /f "tokens=1,2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "type=%%b")
for /f "tokens=2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "data=%%b")
if "%type%"=="MinVmVersionForCpuBasedMitigations" goto regsz
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v %type% /t REG_DWORD /d "%data%" /f >nul 2>&1
goto continue2
:regsz
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v %type% /t REG_SZ /d "%data%" /f >nul 2>&1
:continue2
if "%line0%"=="%line1%" goto nexta
set /a "line0"="%line0%+1"
goto loopa
:nexta
timeout /t 1 /nobreak >nul

:restore1b
cls
echo.
echo %bw%=============================================================================================================
echo                      Restore Speculative Execution Protection Registry Settings from Backup
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo  Restored Registry Settings:%bg%
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsnf10rs1b ) else ( goto fsf10rs1b )
:fsf10rs1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" ^| find "REG_DWORD"') DO set/a fs10rs1b=%%H > nul
echo  FeatureSettings %fs10rs1b%
:fsnf10rs1b
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsonf10rs1b ) else ( goto fsof10rs1b )
:fsof10rs1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" ^| find "REG_DWORD"') DO set/a fso10rs1b=%%H > nul
echo  FeatureSettingsOverride %fso10rs1b%
:fsonf10rs1b
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsomnf10rs1b ) else ( goto fsomf10rs1b )
:fsomf10rs1b
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" ^| find "REG_DWORD"') DO set/a fsom10rs1b=%%H > nul
echo  FeatureSettingsOverrideMask %fsom10rs1b%
:fsomnf10rs1b
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto mvvmnf10rs1b ) else ( goto mvvmf10rs1b )
:mvvmf10rs1b
for /f "tokens=2* skip=2" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations"') DO (set "mvvm10rs1b=%%b") > nul
echo  MinVmVersionForCpuBasedMitigations %mvvm10rs1b%
:mvvmnf10rs1b
echo %bw%=============================================================================================================
call :showbackup
echo.
echo * The Speculative Execution Protection Registry Settings have been Restored from Backup.
echo.
echo * The Computer needs to be Restarted for the Changes to take effect.
echo.
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Logon?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] Exit without Restarting.
echo.
echo.
set "m25="
set /P "m25=Type an Option Number and Press Enter: "
(
IF "%m25%"=="1" goto restart
IF "%m25%"=="2" goto restart2
IF "%m25%"=="3" goto mainmenu
IF "%m25%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto restore1b

:backupnf
cls
echo.
echo %bw%=============================================================================================================
echo                        Backup Current Speculative Execution Protection Registry Settings
echo %bw%=============================================================================================================
call :showcurrent
call :showbackup
echo.
echo  Options:
echo.
echo  [1] Backup the Current Speculative Execution Protection Registry Settings now?
echo.
echo  [2] Go back to the Reset Registry Settings Menu.
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m26="
set /P "m26=Type an Option Number and Press Enter: "
(
IF "%m26%"=="1" goto savebackup
IF "%m26%"=="2" goto menu10
IF "%m26%"=="3" goto mainmenu
IF "%m26%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto backupnf

:savebackup
echo y | reg delete "HKEY_CURRENT_USER\Software\1_MSEPSS_First_Run_Registry_Backup" /f >nul 2>&1
call :regbackup
cls
echo.
echo %bw%=============================================================================================================
echo                     Saved Current Speculative Execution Protection Registry Settings to Backup
echo %bw%=============================================================================================================
call :showcurrent
call :showbackup
timeout /t 5 /nobreak >nul
goto menu10

:menu11
cls
echo.
echo %bw%=============================================================================================================
echo                                 SpeculationControl Module Installation Menu
echo %bw%=============================================================================================================%bg%
if exist "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" (
goto mf11 ) else ( goto nm11 ) >nul 2>&1
:mf11
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
goto mf2
:nm11
echo %br%* SpeculationControl Module Package not Found!
:mf2
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] SpeculationControl Module Overview and Usage Information.(Weblink)
echo.
echo  [2] Check if an Updated SpeculationControl Module Package is Available Online?
echo.
echo  [3] Download and Install the Latest SpeculationControl Module Package?
echo.
echo  [4] Remove Older SpeculationControl Module Packages and Clean Install the Latest Version?
echo.
echo  [5] Open the SpeculationControl Folder?
echo.
echo  [6] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m27="
set /P "m27=Type an Option Number and Press Enter: "
(
IF "%m27%"=="1" goto overviewinfo2
IF "%m27%"=="2" goto menu11a
IF "%m27%"=="3" goto menu11b
IF "%m27%"=="4" goto menu11c
IF "%m27%"=="5" goto menu11d
IF "%m27%"=="6" goto mainmenu
IF "%m27%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu11

:overviewinfo2
start "" "https://github.com/Microsoft/SpeculationControl"
goto menu11

:menu11a
cls
start "" "https://aka.ms/SpeculationControlPS"
goto menu11

:menu11b
cls
echo.
echo %bw%=============================================================================================================
echo                       Download and Install the Latest SpeculationControl Module Package
echo %bw%=============================================================================================================%bg%
if exist "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" (
goto mf11b ) else ( goto nm11b ) >nul 2>&1
:mf11b
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
goto mf2b
:nm11b
echo %br%* SpeculationControl Module Package not Found!
:mf2b
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Download and Install the Latest SpeculationControl Module Package now? Internet Connection Required.
echo.
echo  [2] Go back to the SpeculationControl Module Package Installation Menu?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m28="
set /P "m28=Type an Option Number and Press Enter: "
(
IF "%m28%"=="1" goto menu11bb
IF "%m28%"=="2" goto menu11
IF "%m28%"=="3" goto mainmenu
IF "%m28%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu11b

:menu11bb
cls
echo.
echo %bw%=============================================================================================================
echo                    Downloading and Installing the Latest SpeculationControl Module Package
echo %bw%=============================================================================================================
echo.
PowerShell.exe -Command "Install-Module -Name SpeculationControl -force"
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
timeout /t 5 /nobreak >nul
goto menu11

:menu11c
cls
echo.
echo %bw%=============================================================================================================
echo          Remove Older SpeculationControl Module Packages and Clean Install the Latest Version
echo %bw%=============================================================================================================%bg%
if exist "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" (
goto mf11c ) else ( goto nm11c ) >nul 2>&1
:mf11c
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
goto mf2c
:nm11c
echo %br%* SpeculationControl Module Package not Found!
:mf2c
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Remove Older SpeculationControl Module Packages and Clean Install the Latest Version now?
echo      Internet Connection Required.
echo.
echo  [2] Go back to the SpeculationControl Module Package Installation Menu?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m29="
set /P "m29=Type an Option Number and Press Enter: "
(
IF "%m29%"=="1" goto menu11cc
IF "%m29%"=="2" goto menu11
IF "%m29%"=="3" goto mainmenu
IF "%m29%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu11c

:menu11cc
cls
echo.
echo %bw%=============================================================================================================
echo            Remove Older SpeculationControl Module Packages and Clean Install the Latest Version
echo %bw%=============================================================================================================
echo.
PowerShell.exe -Command "Uninstall-Module -Name 'SpeculationControl' -AllVersions -Force -Verbose"
PowerShell.exe -Command "Install-Module -Name SpeculationControl -force"
cls
echo.
echo %bw%=============================================================================================================
echo            Remove Older SpeculationControl Module Packages and Clean Install the Latest Version
echo %bw%=============================================================================================================
echo.
if exist "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" (
goto mf11cc ) else ( goto nm11cc) >nul 2>&1
:mf11cc
dir "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl" /s /b /o:n /a:d
goto mf2cc
:nm11cc
echo %br%* SpeculationControl Module Package not Found!
:mf2cc
timeout /t 5 /nobreak >nul
goto menu11

:menu11d
cls
start "" "C:\Program Files\WindowsPowerShell\Modules\SpeculationControl"
goto menu11

:menu12
cls
echo.
echo %bw%=============================================================================================================
echo                                 More Information and References.(Weblinks)
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo   [1] "Meltdown and Spectre"
echo.
echo   [2] "RIDL and Fallout: MDS attacks"
echo.
echo   [3] "ZombieLoad Attack"
echo.
echo   [4] "Plunder Volt"
echo.
echo   [5] "CacheOut"
echo.
echo   [6] "Foreshadow"
echo.
echo   [7] "LVI - Hijacking Transient Execution with Load Value Injection "
echo.
echo   [8] "Software Guidance for Security Advisories"
echo.
echo   [9] "Protect your Windows devices against speculative execution side-channel attacks"
echo.
echo  [10] "Windows guidance to protect against speculative execution side-channel vulnerabilities"
echo.
echo  [11] "Protecting guest virtual machines from CVE-2017-5715 (branch target injection)"
echo.
echo  [12] "Windows client guidance for IT Pros to protect against speculative execution side-channel
echo        vulnerabilities"
echo.
echo  [13] TenForums.com "Windows client guidance for IT Pros to protect against speculative
echo       execution side-channel vulnerabilities" Discussion Thread.
echo.
echo  [14] "Summary of Intel microcode updates"
echo.
echo  [15] "Intel Microcode Update Guidance.pdf"
echo.
echo  [16] "Intel(R) Product Security Center Advisories"
echo.
echo  [17] "AMD Product Security"
echo.
echo  [18] "Understanding Get-SpeculationControlSettings PowerShell script output"
echo.
echo  [19] "How to back up and restore the registry in windows"
echo.
echo  [20] "Protect yourself online"
echo.
echo  [21] "Guidance for disabling Intel(R) Transactional Synchronization Extensions (Intel(R) TSX) capability"
echo.
echo  [22] "Mitigations for Jump Conditional Code Erratum.pdf"
echo.
echo  [23] "Processors Affected: Microarchitectural Data Sampling"
echo.
echo  [24] Go to the Main Menu
echo.
echo.
echo  [00] %exit%
echo.
echo.
set "m30="
set /P "m30=Type an Option Number and Press Enter: "
(
IF "%m30%"=="1" goto link1
IF "%m30%"=="2" goto link2
IF "%m30%"=="3" goto link3
IF "%m30%"=="4" goto link4
IF "%m30%"=="5" goto link5
IF "%m30%"=="6" goto link6
IF "%m30%"=="7" goto link7
IF "%m30%"=="8" goto link8
IF "%m30%"=="9" goto link9
IF "%m30%"=="10" goto link10
IF "%m30%"=="11" goto link11
IF "%m30%"=="12" goto link12
IF "%m30%"=="13" goto link13
IF "%m30%"=="14" goto link14
IF "%m30%"=="15" goto link15
IF "%m30%"=="16" goto link16
IF "%m30%"=="17" goto link17
IF "%m30%"=="18" goto link18
IF "%m30%"=="19" goto link19
IF "%m30%"=="20" goto link20
IF "%m30%"=="21" goto link21
IF "%m30%"=="22" goto link22
IF "%m30%"=="23" goto link23
IF "%m30%"=="24" goto mainmenu
IF "%m30%"=="00" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu12

:link1
start "" "https://meltdownattack.com/"
goto menu12

:link2
start "" "https://mdsattacks.com/"
goto menu12

:link3
start "" "https://zombieloadattack.com/"
goto menu12

:link4
start "" "https://plundervolt.com/"
goto menu12

:link5
start "" "https://cacheoutattack.com/"
goto menu12

:link6
start "" "https://foreshadowattack.eu/"
goto menu12

:link7
start "" "https://lviattack.eu/"
goto menu12

:link8
start "" "https://software.intel.com/security-software-guidance/"
goto menu12

:link9
start "" "https://support.microsoft.com/en-us/help/4073757/protect-windows-devices-from-speculative-execution-side-channel-attack"
goto menu12

:link10
start "" "https://support.microsoft.com/en-us/help/4457951/windows-server-guidance-to-protect-against-l1-terminal-fault"
goto menu12

:link11
start "" "https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/CVE-2017-5715-and-hyper-v-vms"
goto menu12

:link12
start "" "https://support.microsoft.com/en-us/help/4073119/protect-against-speculative-execution-side-channel-vulnerabilities-in"
goto menu12

:link13
start "" "https://www.tenforums.com/windows-10-news/132607-windows-client-guidance-pros-protect-against-speculative.html#post1633034"
goto menu12

:link14
start "" "https://support.microsoft.com/en-us/help/4093836/summary-of-intel-microcode-updates"
goto menu12

:link15
start "" "https://www.intel.com/content/dam/www/public/us/en/security-advisory/documents/ipu-2019-2-microcode-update-guidance.pdf"
goto menu12

:link16
start "" "https://www.intel.com/content/www/us/en/security-center/default.html"
goto menu12

:link17
start "" "https://www.amd.com/en/corporate/product-security"
goto menu12

:link18
start "" "https://support.microsoft.com/en-us/help/4074629/understanding-the-output-of-get-speculationcontrolsettings-powershell"
goto menu12

:link19
start "" "https://support.microsoft.com/en-us/help/322756/how-to-back-up-and-restore-the-registry-in-windows"
goto menu12

:link20
start "" "https://support.microsoft.com/en-us/hub/4099151/windows-security-help"
goto menu12

:link21
start "" "https://support.microsoft.com/en-za/help/4531006/guidance-for-disabling-intel-transactional-synchronization-extensions"
goto menu12

:link22
start "" "https://www.intel.com/content/dam/support/us/en/documents/processors/mitigations-jump-conditional-code-erratum.pdf"
goto menu12

:link23
start "" "https://software.intel.com/security-software-guidance/insights/processors-affected-microarchitectural-data-sampling"
goto menu12

:menu13
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v RebootPending | Find "%tle%" >nul 2>&1
if "%ERRORLEVEL%"=="0" ( goto yesrp ) else ( goto norp )
:yesrp
set skiprpaa=noskipb1
set skiprp=noskipa1
goto noskip114
:norp
set skiprpaa=yesskipb4
set skiprp=yesskipa4
:noskip114
cls
echo.
echo %bw%=============================================================================================================
echo                                             Restart Options Menu
echo %bw%=============================================================================================================
goto %skiprpaa%
:noskipb1
echo.
echo %bg%* %rprc%
:yesskipb2
echo.%bw%
echo * Please ensure any Unfinished work is Saved before Restarting.
echo.
echo %bw%=============================================================================================================
timeout /t 1 /nobreak >nul
echo.
echo  Options:
echo.
echo  [1] Restart the Computer now?
echo.
echo  [2] Restart the Computer now and Launch the Script one time after Login?
echo.
echo  [3] Go to the Main Menu.
echo.
echo.
echo  [0] %exit%
echo.
echo.
set "m31="
set /P "m31=Type an Option Number and Press Enter: "
(
IF "%m31%"=="1" goto restart
IF "%m31%"=="2" goto restart2
IF "%m31%"=="3" goto mainmenu
IF "%m31%"=="0" goto exit1
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto menu13

:restart
echo.
echo.
shutdown /r /t 30 /c "Restarting the system to apply registry changes"
:restart1a
cls
echo.
echo %bw%=============================================================================================================
echo * The Computer will Automatically Restart in 30 seconds...
echo %bw%=============================================================================================================
echo.
echo  Options:
echo.
echo  [1] Restart the Computer Immediately.
echo.
echo  [0] Cancel the Restart and Go to the Main Menu.
echo.
echo.
set "m32="
set /P "m32=Type an Option Number and Press Enter: "
(
IF "%m32%"=="1" goto restartnow
IF "%m32%"=="0" goto abort
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto restart1a

:restart2
echo.
echo.
echo y | reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce /v %~n0 /d %~dpnx0 /f
shutdown /r /t 30 /c "Restarting the system to apply registry changes"
:restart1b
cls
echo.
echo %bw%=============================================================================================================
echo * The Computer will Automatically Restart in 30 seconds...
echo %bw%=============================================================================================================
echo.
echo  Options:
echo.
echo  [1] Restart the Computer Immediately.
echo.
echo  [0] Cancel the Restart and Go to the Main Menu.
echo.
echo.
set "m33="
set /P "m33=Type an Option Number and Press Enter: "
(
IF "%m33%"=="1" goto restartnow
IF "%m33%"=="0" goto abort
)
echo.
echo  %br%Incorrect Selection...%bw%
rundll32 user32.dll,MessageBeep
timeout /t 2 /nobreak >nul
goto restart1b

:restartnow
shutdown /r /t 0
exit

:abort
shutdown /a
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce /v %~n0 /f >nul
goto mainmenu

:exit1
echo.
echo.
echo The Console Window will Automatically Close in 5 seconds...
timeout /t 5 /nobreak >nul
exit

:minvmq
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v MinVmVersionForCpuBasedMitigations >nul 2>&1
if "%ErrorLevel%"=="0" ( goto fMinVmV ) else ( goto nfMinVmV )
:fMinVmV
echo y | reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v MinVmVersionForCpuBasedMitigations >nul
:nfMinVmV
goto eof

:regbackup
:: Auto Backup Current Registry Settings on the First Run to the Current Directory of this Script.
echo y | reg delete "HKEY_CURRENT_USER\Software\1_MSEPSS_First_Run_Registry_Backup" /f >nul 2>&1
if not exist "%CD%\First_Run_Registry_Settings_Backup" mkdir "%CD%\First_Run_Registry_Settings_Backup"
if exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" goto backupdone
echo. > "%CD%\First_Run_Registry_Settings_Backup\Backup.txt"
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsnf ) else ( goto fsf )
:fsf
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" ^| find "REG_DWORD"') DO set /a fs=%%H > nul
echo 1 FeatureSettings %fs% > "%CD%\First_Run_Registry_Settings_Backup\Backup.txt
goto fsf_
:fsnf
set "sfl=>"
goto sfl_
:fsf_
set "sfl=>>"
:sfl_
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsonf ) else ( goto fsof )
:fsof
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" ^| find "REG_DWORD"') DO set /a fso=%%H > nul
echo 2 FeatureSettingsOverride %fso% %sfl% "%CD%\First_Run_Registry_Settings_Backup\Backup.txt"
:fsonf
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto fsomnf ) else ( goto fsomf )
:fsomf
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" ^| find "REG_DWORD"') DO set /a fsom=%%H > nul
echo 3 FeatureSettingsOverrideMask %fsom% >> "%CD%\First_Run_Registry_Settings_Backup\Backup.txt"
:fsomnf
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( goto backupdone ) else ( goto mvvmf )
:mvvmf
for /f "tokens=2* skip=2" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations"') DO (set "mvvm=%%b") > nul
echo 4 MinVmVersionForCpuBasedMitigations %mvvm% >> "%CD%\First_Run_Registry_Settings_Backup\Backup.txt"
:backupdone
goto eof

:showcurrent
set linec=0
timeout /t 1 /nobreak >nul
echo  Current Registry Settings:%bg%
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec=%linec%+1&goto fsnf10 ) else ( goto fsf10 )
:fsf10
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettings" ^| find "REG_DWORD"') DO set /a fs10=%%H > nul
echo  FeatureSettings %fs10%
:fsnf10
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec=%linec%+1&goto fsonf10 ) else ( goto fsof10 )
:fsof10
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverride" ^| find "REG_DWORD"') DO set /a fso10=%%H > nul
echo  FeatureSettingsOverride %fso10%
:fsonf10
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec=%linec%+1&goto fsomnf10 ) else ( goto fsomf10 )
:fsomf10
for /f "tokens=1-9" %%F in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "FeatureSettingsOverrideMask" ^| find "REG_DWORD"') DO set /a fsom10=%%H > nul
echo  FeatureSettingsOverrideMask %fsom10%
:fsomnf10
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations" >nul 2>&1
if %ERRORLEVEL% EQU 1 ( set /a linec=%linec%+1&goto mvvmnf10 ) else ( goto mvvmf10 )
:mvvmf10
for /f "tokens=2* skip=2" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" /v "MinVmVersionForCpuBasedMitigations"') DO (set "mvvm10=%%b") > nul
echo  MinVmVersionForCpuBasedMitigations %mvvm10%
:mvvmnf10
if "%linec%"=="4" echo  %bg%None
echo %bw%=============================================================================================================
goto eof

:showbackup
set "data="
set "type="
timeout /t 1 /nobreak >nul
if exist "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" (
goto showbackup1 ) else ( goto bnf ) >nul 2>&1
:bnf
echo  Backup Registry Settings:
echo  %br%Backup File not Found!%bw%
goto nextab
:showbackup1
find /c "1 FeatureSettings" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto nextab_
find /c "2 FeatureSettingsOverride" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto nextab_
find /c "3 FeatureSettingsOverrideMask" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto nextab_
find /c "4 MinVmVersionForCpuBasedMitigations" "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" >nul 2>&1
if %errorlevel% equ 0 goto nextab_
goto nextab
:nextab_
echo  Backup Registry Settings:%bg%
set line1=0
set line0=1
set loop=0
for /f "usebackq" %%A in (`TYPE "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| find /v /c "" `) DO set line1=%%A
:loopab
set /a loop=%loop%+1
for /f "tokens=1,2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "type=%%b") >nul
for /f "tokens=2* delims= " %%a in ('find /n /v "" ^< "%CD%\First_Run_Registry_Settings_Backup\Backup.txt" ^| findstr "^\[%line0%\]" ') DO (set "data=%%b") >nul
echo. %type% %data%
if "%line0%"=="%line1%" goto nexta_b2
set /a "line0"="%line0%+1"
goto loopab
:nextab
echo  Backup Registry Settings:
echo  %bg%None
:nexta_b2
echo %bw%=============================================================================================================
goto eof

:eof
```


----------



## ThrashZone (Oct 23, 2021)

W1zzard said:


> press windows key, type tamper, click first option, go down a few options and turn it off manually. that's the only way, otherwise "tamper protection" would be useless if you could disable it from script


Hi,
Yep that is exactly how I did it
I was greeted with some changes are restricted contact IT admin lol 

Turned out to be mbam premium tamper protection had a hold on the feature.
I always thought mbam tamper protection was just for it's self not defender too 

11 i had no issues though just on win-10 
Done and dusted thanks


----------



## W1zzard (Oct 26, 2022)

Saved Windows 11 21H2 code, working on update for 22H2 in 1st post 

- Install without Internet, so you can create an offline user
- Install on systems without TPM, UEFI or other requirements: https://www.techpowerup.com/287584/windows-11-tpm-requirement-bypass-it-in-5-minutes
- name the user "TPU" (the user will be deleted at the end of the scripts and you'll be using "Administrator")
- Install VGA driver, from USB, still without network, so Windows Update won't install a graphics driver automatically. Protip: use NVCleanstall
- Run Windows Update, update everything
- No need to update Windows Store apps
- Disable Defender "Tamper protection" via Settings App
- Run the below in admin-rights cmd shell.


```
rem Turn off Windows Startup Recovery Screen
bcdedit /set {current} bootstatuspolicy ignoreallfailures
bcdedit /set {default} recoveryenabled no

rem Create new pagefile. (2nd line indented because wmic will eat a character when pasting)
wmic pagefileset delete
  wmic pagefileset create name=C:\pagefile.sys
  wmic pagefileset set InitialSize=16384,MaximumSize=16384

rem Enable Administrator account
net user Administrator /active:yes

rem Disable Error Reporting
reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1 /f

rem Disable automatic TCG/Opal disk locking on supported SSD drives with PSID
reg add HKLM\Software\Policies\Microsoft\Windows\EnhancedStorageDevices /v TCGSecurityActivationDisabled /t REG_DWORD /d 1 /f

rem Control Panel shows Large Icons
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v ForceClassicControlPanel /t REG_DWORD /d 1 /f

rem Disable UAC
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f

rem Disable discovery of LAN devices like printers
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private /f /v AutoSetup /t REG_DWORD /d 0

rem Delete all printers discovered so far
powershell "Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}"

rem Set Ethernet connection to private
powershell Set-NetConnectionProfile -InterfaceAlias Ethernet* -NetworkCategory private

rem Set all "unknown network"s to private by default (such adapters are created by VMWare and VirtualBox for their networking, we don't want the Firewall popup)
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" /v Category /t REG_DWORD /d 1 /f

rem Disable Warnings due to Firewall / Defender being disabled
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\Software\Microsoft\Windows Defender Security Center\Notifications" /v DisableNotifications /t REG_DWORD /d 1 /f

rem Disable Windows Firewall for private network
netsh advfirewall set private state off

rem Workaround for bug that shows Firewall "application blocked" messages, despite Firewall being disabled for private network
netsh firewall set notifications mode=disable profile=standard

rem Disable Windows Defender. For this to work you have to manually disable "Tamper protection"
powershell "if ((Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows Defender\Features').TamperProtection -eq 4) { exit 0; } ; Write-Output 'Windows Defender can not be disabled, Tamper Protection is still active' '' 'Disable Tamper Protection manually, then press OK' | msg /w *"
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Spynet" /v SpyNetReporting /t REG_DWORD /d 0 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Spynet" /v SubmitSamplesConsent /t REG_DWORD /d 2 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer" /v SmartScreenEnabled /t REG_SZ /d "Off" /f
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v DisableRoutinelyTakingAction /t REG_DWORD /d 1 /f
reg delete HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v SecurityHealth /f

rem Disable "Consumer Features" (aka downloading apps from the internet automatically)
reg add HKLM\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f

rem Disable Lock Screen
reg add HKLM\Software\Policies\Microsoft\Windows\Personalization /v NoLockScreen /t REG_DWORD /d 1 /f

rem Remove Logon Wallpaper
reg add HKLM\Software\Policies\Microsoft\Windows\System /v DisableLogonBackgroundImage /t REG_DWORD /d 1 /f

rem Remove Meet Now icon
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v HideSCAMeetNow /t REG_DWORD /d 1 /f

rem Disable One Drive
reg add HKLM\Software\Policies\Microsoft\Windows\OneDrive /v DisableFileSyncNGSC /t REG_DWORD /d 1 /f
start /wait %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
rd "%PROGRAMDATA%\Microsoft OneDrive" /Q /S
reg delete "HKEY_USERS\S-1-5-19\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
reg delete "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
reg load HKLM\DEFAULT c:\users\default\ntuser.dat
reg delete HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run /v OneDriveSetup /f
reg unload HKLM\DEFAULT

rem Disable Hibernate
powercfg -h off

rem Turn off sleep mode
powercfg.exe -x -standby-timeout-ac 0

rem Set 4 hours screen blank timeout
powercfg.exe -x -monitor-timeout-ac 240

rem Disable System Restore and delete restore points
powershell disable-computerrestore c:
vssadmin delete shadows /all /quiet

rem Set Timezone
tzutil /s "W. Europe Standard Time"

rem Disable reboot on Bluescreen, and no dump
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v CrashDumpEnabled /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v LogEvent /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v SendAlert /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\CrashControl /v AutoReboot /t REG_DWORD /d 0 /f

rem Don't allow Remote Assistance
reg add "HKLM\System\CurrentControlSet\Control\Remote Assistance" /v fAllowToGetHelp /t REG_DWORD /d 0 /f

rem Enable Remote Desktop
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

rem Allow Remote Desktop without password
reg add HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v LimitBlankPasswordUse /t REG_DWORD /d 0 /f

rem Disable Edge Browser preload on startup. We'll never use it anyway, saves memory and startup time
reg add HKLM\Software\Policies\Microsoft\MicrosoftEdge\Main /v AllowPrelaunch /t REG_DWORD /d 0 /f
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v StartupBoostEnabled /t REG_DWORD /d 0 /f

rem Disable Edge Browser (Chromium) first run experience
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v HideFirstRunExperience /t REG_DWORD /d 1 /f

rem Disable Look for App in Store prompt when opening unknown file type
reg add HKLM\Software\Policies\Microsoft\Windows\Explorer /v NoUseStoreOpenWith /t REG_DWORD /d 1 /f

rem Disable Windows Program Compatibility Assistant
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v DisablePCA /t REG_DWORD /d 1 /f

rem Disable Inventory collecting data and sending the info to Microsoft
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v DisableInventory /t REG_DWORD /d 1 /f

rem Disable Application Telemetry
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\AppCompat /v AITEnable /t REG_DWORD /d 0 /f

rem Disable Shared Experiences
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\System /v EnableCdp /t REG_DWORD /d 0 /f

rem Uninstall Windows Update Health Tools
wmic product where name='Microsoft Update Health Tools' call uninstall

rem Remvoe "Chat" from Taskbar and block automatic Teams installation
rem We need to take ownership of the key first
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://www.techpowerup.com/wizzard/SetACL.exe', '%TEMP%\SetACL.exe');
%TEMP%\SetACL.exe -on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn setowner -ownr "n:Everyone"
%TEMP%\SetACL.exe -on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn ace -ace "n:Everyone;p:full"
del %TEMP%\SetACL.exe

reg add "HKLM\Software\Policies\Microsoft\Windows\Windows Chat" /f /v ChatIcon /t REG_DWORD /d 3
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Communications /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /f /v TaskbarMn /t REG_DWORD /d 0

rem Remove useless Windows components
dism /online /norestart /disable-feature /featurename:Printing-PrintToPDFServices-Features
dism /online /norestart /disable-feature /featurename:Printing-XPSServices-Features
dism /online /norestart /disable-feature /featurename:WorkFolders-Client
dism /online /norestart /disable-feature /featurename:Printing-Foundation-Features
dism /online /norestart /disable-feature /featurename:Printing-Foundation-InternetPrinting-Client
dism /online /norestart /disable-feature /featurename:MSRDC-Infrastructure
dism /online /norestart /disable-feature /featurename:SmbDirect
dism /online /norestart /disable-feature /featurename:MediaPlayback
dism /online /norestart /disable-feature /featurename:WCF-TCP-PortSharing45
dism /online /norestart /disable-feature /featurename:WCF-Services45
dism /online /norestart /disable-feature /featurename:WindowsMediaPlayer

rem Install .NET 3.5 Framework, some older apps and games need this, and you can't install it on demand once Windows Update is disabled
dism /online /norestart /enable-feature /featurename:NetFx3 /all

rem Remove useless optional features
dism /online /norestart /Remove-Capability /CapabilityName:App.StepsRecorder~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:App.Support.QuickAssist~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Browser.InternetExplorer~~~~0.0.11.0
dism /online /norestart /Remove-Capability /CapabilityName:DirectX.Configuration.Database~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Hello.Face.20134~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.Handwriting~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.Speech~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Language.TextToSpeech~~~en-US~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:MathRecognizer~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Media.WindowsMediaPlayer~~~~0.0.12.0
dism /online /norestart /Remove-Capability /CapabilityName:Microsoft.Windows.WordPad~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:OneCoreUAP.OneSync~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Print.Management.Console~~~~0.0.1.0
dism /online /norestart /Remove-Capability /CapabilityName:Print.Fax.Scan~~~~0.0.1.0

rem Do not remove OCR or Windows will show "Something happened, and we couldn't install a feature" a few hours after cleanup
rem dism /online /norestart /Remove-Capability /CapabilityName:Language.OCR~~~en-US~0.0.1.0

rem Remove a lot of unnecessary apps

powershell "Get-AppXPackage | Where NonRemovable -Match false | Where IsFramework -Match false | Where Name -NotMatch '.*Windows(Store|Notepad|Calculator|Terminal)|NVIDIAControlPanel.*' | Remove-AppXPackage"
powershell "sleep 5"
powershell "Get-AppXProvisionedPackage -online | Where DisplayName -NotMatch '.*Windows(Store|Notepad|Calculator|Terminal)|NVIDIAControlPanel.*' | ForEach-Object { try { Write-Host $_.DisplayName ; Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName  } catch { Write-Host $_ } }"

rem Set Computer name
powershell "Rename-Computer -NewName VGATEST"

rem Finished
```

*Download and install Firefox silently, make it default browser and adjust settings to remove telemetry and other junk*

```
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US','%TEMP%\ff.exe'); Start-Process %TEMP%\ff.exe /s -NoNewWindow -Wait; Remove-Item %TEMP%\ff.exe"

echo pref("general.config.filename", "firefox.cfg"); > "C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js"
echo pref("general.config.obscure_value", 0); >> "C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js"

echo lockPref("browser.startup.homepage_override.mstone", "ignore"); > "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("browser.messaging-system.whatsNewPanel.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("datareporting.healthreport.uploadEnabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("app.shield.optoutstudies.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("extensions.pocket.enabled", false); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"
echo lockPref("browser.toolbars.bookmarks.visibility", "never"); >> "C:\Program Files\Mozilla Firefox\firefox.cfg"

rem Looks complicated, but this seems to be the only thing that works, let me know if you know an alternative
Powershell "Start-Process -FilePath 'C:\Program Files\Mozilla Firefox\firefox.exe' -ArgumentList '-setDefaultBrowser' ; Start-Sleep -s 3 ; Start-Process -FilePath 'C:\Program Files\Mozilla Firefox\firefox.exe' -ArgumentList '-setDefaultBrowser' ; Start-Sleep -s 3 ; taskkill /im firefox.exe ; taskkill /im firefox.exe ; taskkill /f /im systemsettings.exe"
```

User-specific (run after logging in as Administrator)

```
rem Install AnyDesk 
rem PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://download.anydesk.com/AnyDesk-CM.exe', '%TEMP%\ad.exe')" && start /wait %TEMP%\ad.exe --remove-first --install "%ProgramFiles%\AnyDesk" --start-with-win --update-manually --create-shortcuts --create-desktop-icon && del %TEMP%\ad.exe

rem Delete TPU user and user profile
net user TPU /delete
powershell "Get-WmiObject Win32_UserProfile | where {$_.localpath -like '*TPU'} | Remove-WmiObject"

rem Disable Windows Game DVR and Game Bar
reg add HKCU\Software\Microsoft\GameBar /v UseNexusForGameBarEnabled /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR /v GameDVR_Enabled /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR /v AppCaptureEnabled /t REG_DWORD /d 0 /f
rem Add workaround for bug that shows "You'll need a new app to open this ms-gamingoverlay" when starting a game
reg add HKEY_CLASSES_ROOT\ms-gamingoverlay /t REG_SZ /d "URL:ms-gamingoverlay" /f

rem Disable Game Mode
reg add HKCU\Software\Microsoft\GameBar /v AutoGameModeEnabled /t REG_DWORD /d 0 /f

rem Disable Web Search
reg add HKCU\Software\Policies\Microsoft\Windows\Explorer /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f

rem Hide Search Box from Task Bar
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Search /v SearchboxTaskbarMode /t REG_DWORD /d 0 /f

rem Hide Task View button
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowTaskViewButton /t REG_DWORD /d 0 /f

rem Windows Explorer Start on This PC instead of Quick Access
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 1 /f

rem Disable frequent/recent items in Explorer Quick Access
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v ShowFrequent /t REG_DWORD /d 0 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer /v ShowRecent /t REG_DWORD /d 0 /f

rem Disable "Let's finish up Windows" nag screen
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement /v ScoobeSystemSettingEnabled /t REG_DWORD /d 0 /f

rem Disable Windows Feedback
reg add HKCU\SOFTWARE\Microsoft\Siuf\Rules /v NumberOfSIUFInPeriod /t REG_DWORD /d 0 /f

rem Show My Computer on Desktop
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t REG_DWORD /d 0 /f

rem Disable Recycle Bin
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoRecycleFiles /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v ConfirmFileDelete /t REG_DWORD /d 1 /f

rem Don't show Recycle Bin on Desktop
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu /v "{645FF040-5081-101B-9F08-00AA002F954E}" /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v "{645FF040-5081-101B-9F08-00AA002F954E}" /t REG_DWORD /d 1 /f

rem Set 24 hour time format
reg add "HKCU\Control Panel\International" /v iFirstDayOfWeek /t REG_SZ /d "0" /f
reg add "HKCU\Control Panel\International" /v sShortDate /t REG_SZ /d "yyyy-MM-dd" /f
reg add "HKCU\Control Panel\International" /v sShortTime /t REG_SZ /d "HH:mm" /f
reg add "HKCU\Control Panel\International" /v sTimeFormat /t REG_SZ /d "HH:mm:ss" /f

rem Turn off Sticky Key when Shift is pressed 5 times
reg add "HKCU\Control Panel\Accessibility\StickyKeys" /v Flags /t REG_SZ /d "506" /f

rem Show file extensions in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t  REG_DWORD /d 0 /f

rem Show Hidden Files in Explorer
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f

rem Always show more details in file copy dialog
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager /v EnthusiastMode /t REG_DWORD /d 1 /f

rem Set "Do this for all current items" checkbox by default
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager /v ConfirmationCheckBoxDoForAll /t REG_DWORD /d 1 /f

rem Expand left side tree of current folder on Explorer open
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v NavPaneExpandToCurrentFolder /t REG_DWORD /d 1 /f

rem Disable "Let Windows manage my default printer"
reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" /f /v LegacyDefaultPrinterMode /t REG_DWORD /d 1

rem Turn off Wallpaper
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers /v BackgroundType /t REG_DWORD /d 1 /f
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "" /f
reg add "HKCU\Control Panel\Desktop" /v LastUpdated /t REG_DWORD /d 0xffffffff /f
reg add "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "45 125 154" /f

rem Remove 10 second startup delay for application restore
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize /v StartupDelayInMSec /t REG_DWORD /d 0 /f

rem Unpin everything from Taskbar
powershell "(New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items()| foreach { ($_).Verbs() | ?{$_.Name.Replace('&', '') -match 'Unpin from taskbar'} | %{$_.DoIt()}  }"

rem Restore classic context menus / disable "Show more options" menu entry on right-click
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /t REG_SZ /d ""

rem Remove secondary en-US keyboard that gets added when keyboard is set to DE with US region
reg delete "HKCU\Control Panel\International\User Profile\en-US" /v "0409:00000409" /f
reg delete "HKCU\Control Panel\International\User Profile System Backup\en-US" /v "0409:00000409" /f
reg delete "HKCU\Keyboard Layout\Preload" /v "2" /f
reg delete "HKCU\Keyboard Layout\Substitutes" /v "d0010409" /f

rem Remove desktop.ini files from Desktop
del /a C:\Users\Public\Desktop\desktop.ini
del /a C:\Users\Administrator\Desktop\desktop.ini

rem Remove Edge from Desktop (depending on the Edge version this exists in one or the other folder)
del /a "C:\Users\Administrator\Desktop\Microsoft Edge.lnk"
del /a "C:\Users\Public\Desktop\Microsoft Edge.lnk"
```

*Permanently disable Windows Update*
Please note, once disabled, you can only restore MANUAL updates, the (default) automatic behavior is gone

```
rem Stop and delete Windows Update Medic Service (it re-enables Windows Update)
net stop WaasMedicSvc
takeown /f %SYSTEMROOT%\System32\WaaSMedicSvc.dll
cacls %SYSTEMROOT%\System32\WaaSMedicSvc.dll /e /p "Administrator":f
del %SYSTEMROOT%\System32\WaaSMedicSvc.dll

rem Stop and disable Update Orchestrator Service
net stop UsoSvc
takeown /f %SYSTEMROOT%\System32\usosvc.dll
cacls %SYSTEMROOT%\System32\usosvc.dll /e /p "Administrator":f
ren %SYSTEMROOT%\System32\usosvc.dll usosvc.dll.disabled

rem Stop and disable Windows Update Service
net stop wuauserv
takeown /f %SYSTEMROOT%\System32\wuaueng.dll
cacls %SYSTEMROOT%\System32\wuaueng.dll /e /p "Administrator":f
ren %SYSTEMROOT%\System32\wuaueng.dll wuaueng.dll.disabled

rem Remove scheduled tasks
PowerShell "(New-Object System.Net.WebClient).DownloadFile('https://www.poweradmin.com/paexec/paexec.exe','%TEMP%\paexec.exe');
for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\WaaSMedic\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\WaaSMedic

for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\UpdateOrchestrator\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator

for /f "delims=" %f in ('dir /b %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate') do %TEMP%\paexec -i -s schtasks /delete /f /tn "Microsoft\Windows\WindowsUpdate\%f"
rmdir %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate
copy NUL %WINDIR%\System32\Tasks\Microsoft\Windows\WindowsUpdate

del %TEMP%\paexec.exe
```

*Restore Windows Update (manual updates only)*

```
net stop wuauserv
ren %SYSTEMROOT%\System32\wuaueng.dll.disabled wuaueng.dll
net stop UsoSvc
ren %SYSTEMROOT%\System32\usosvc.dll.disabled usosvc.dll
```

TODO: disable focus asssist


----------



## ThrashZone (Oct 26, 2022)

Hi,
Nice
I use a lot of these goodies but is there one or mostly all of this that kills realbench from running completely ?
Asking for others


----------



## BSim500 (Oct 26, 2022)

W1zzard said:


> Saved Windows 11 21H2 code, working on update for 22H2 in 1st post


Nice list. One line I add in my similar "tweak file" next to the "dism /online /norestart /enable-feature /featurename:NetFx3 /all" is this...


```
dism /online /norestart /enable-feature /featurename:DirectPlay /all
```
... which adds DirectPlay compatibility (that MS include in the ISO but don't install by default and it also isn't included in the usual DirectX9.0c redist package), as I know from experience there are some old school games, eg, original / classic disc versions of Age of Empires 1-2, Commandos Behind Enemy Lines, Diablo 2, etc, that need it. Probably not too useful for a benchmarking test rig, but if any other readers are into classic gaming, they may find some _"it ran under W7 but won't start under W10"_ DirectPlay games can actually be played under W10 with this installed, and W11 may be the same.


----------



## ThrashZone (Dec 9, 2022)

Hi,
On 22h2 I don't see any reference to Home on navigation pane still only old named quick access 








						Add or Remove Home in Navigation Pane of File Explorer in Windows 11  Tutorial
					

Quick access in the navigation pane of File Explorer (Win+E) allows you to quickly access and view your pinned locations, frequent folders, and recent files from one location in Quick Access.  Starting with Windows 11 build 22593, Quick access is now called Home. The name Quick access has been...




					www.elevenforum.com


----------



## stagnationpoint (Dec 13, 2022)

This seems like a great work-around to re-stablish a way to setup Windows 11 using a local account, but is there any feedback on any confirmation this has a realized gain in GPU benchmarking? I am just having a hard time seeing how this differs from just setting up Windows with an online account and then switching it back to local after the fact.


----------



## ThrashZone (Dec 13, 2022)

Hi,
Some of the stuff like any desk/.. are purely personal preference so yeah I cull out some of the stuff.
But for the most part it does help quite a bit.

Off line does not mean crap doesn't run not even local account.


----------



## Zyll Goliat (Dec 13, 2022)

When it comes to the Win 11 updates WUB still working fine and you can switch ON/OFF updates whenever you want.......


----------



## W1zzard (Dec 13, 2022)

stagnationpoint said:


> This seems like a great work-around to re-stablish a way to setup Windows 11 using a local account, but is there any feedback on any confirmation this has a realized gain in GPU benchmarking? I am just having a hard time seeing how this differs from just setting up Windows with an online account and then switching it back to local after the fact.


It's mostly to have a clean base setup without tons of shit running that nobody needs, that could potentially interfere with testing. I don't think it will give you a significant gain in FPS



Zyll Goliat said:


> When it comes to the Win 11 updates WUB still working fine and you can switch ON/OFF updates whenever you want.......


Absolutely. It's another program to run/install/monitor though


----------



## ThrashZone (Dec 13, 2022)

Hi,
Well updating in the op is one of the first things to do before using the scripts
Updating after would tend to reset a lot of stuff so net gain 0.

Start over.


----------



## W1zzard (Dec 13, 2022)

ThrashZone said:


> Hi,
> Well updating in the op is one of the first things to do before using the scripts
> Updating after would tend to reset a lot of stuff so net gain 0.
> 
> Start over.


Windows Update will not revert any of these settings in my experience, unless they push some major update


----------



## ThrashZone (Dec 13, 2022)

W1zzard said:


> Windows Update will not revert any of these settings in my experience, unless they push some major update


Hi,
Yep but never know what update will show up next 
I tend to turn off updates for a while though at least a few months.


----------



## W1zzard (Dec 13, 2022)

ThrashZone said:


> Hi,
> Yep but never know what update will show up next
> I tend to turn off updates for a while though at least a few months.


Yeah for my test systems updates are turned off, because updates can affect performance in subtle ways


----------



## ThrashZone (Dec 13, 2022)

Hi,
Yep think the guy that asked here should realize what the op is for "Benchmarking" it's not really for everyday gaming but I have moved using a lot of the scripts for everyday install use


----------

