@echo off
TITLE Revert MRP WU Driver Blocks.
COLOR 1F
echo.
for /f "tokens=4-5 delims=. " %%i in ('ver') do set "TestWinVer=%%i"
IF %TestWinVer% LSS 10 echo This script only works on Windows 10 Kernels. & GOTO :Finished

cd %systemroot%\system32
call :IsAdmin
CLS
TITLE Revert MRP WU Driver Blocks.
COLOR 1F

:OSARCHSTATUS
SET "OSARCH=x86"
SET "bits="
FOR /f "tokens=2 delims==" %%a in ('wmic os get osarchitecture /value 2^>nul') do set "bits=%%a"
ECHO %bits% | FINDSTR "64" >NUL 2>&1 && SET "OSARCH=x64"
ECHO %bits% | FINDSTR "32" >NUL 2>&1 && SET "OSARCH=x86"
IF /I "%OSARCH%"=="x64" GOTO :DoneArch

IF DEFINED bits IF /I "%bits%"=="64-Bit" SET "OSARCH=x64"
IF DEFINED bits IF /I "%bits%"=="32-Bit" SET "OSARCH=x86"
IF /I "%OSARCH%"=="x64" GOTO :DoneArch

REM Recheck if x86 to make sure it's correct.
ECHO %PROCESSOR_ARCHITECTURE% | FINDSTR "64" >NUL 2>&1 && SET "OSARCH=x64"
ECHO %PROCESSOR_ARCHITECTURE% | FINDSTR "86" >NUL 2>&1 && SET "OSARCH=x86"
IF /I "%OSARCH%"=="x64" GOTO :DoneArch

SET "OSARCH=x64"
IF /I "%PROCESSOR_ARCHITECTURE%"=="x86" IF "%PROCESSOR_ARCHITEW6432%"=="" SET "OSARCH=x86"
IF /I "%OSARCH%"=="x64" GOTO :DoneArch

IF EXIST "%systemdrive%\Program Files (x86)\" SET "OSARCH=x64"
IF NOT DEFINED OSARCH SET "OSARCH=x86"

:DoneArch
echo.
echo Simple script to revert WU Driver blocks used within MRP.
IF DEFINED bits (
echo.
echo OS Architecture: %bits%
echo.
)

reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Device Metadata" /v "PreventDeviceMetadataFromNetwork" /t REG_DWORD /d "0" /f >NUL 2>&1
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\DriverSearching" /v "SearchOrderConfig" /t REG_DWORD /d "2" /f >NUL 2>&1
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\DriverSearching" /v "DontSearchWindowsUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\DriverSearching" /v "DriverUpdateWizardWuSearchEnabled" /t REG_DWORD /d "1" /f >NUL 2>&1
reg add "HKLM\Software\Microsoft\Windows\WindowsUpdate" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
reg add "HKLM\Software\Microsoft\Windows\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
reg add "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1

reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" /v "PreventDeviceMetadataFromNetwork" /f >NUL 2>&1
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DontPromptForWindowsUpdate" /f >NUL 2>&1
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DontSearchWindowsUpdate" /f >NUL 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "DriverUpdateWizardWuSearchEnabled" /t REG_DWORD /d "1" /f >NUL 2>&1
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" /v "SearchOrderConfig" /t REG_DWORD /d "2" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\Microsoft\Windows\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1

Reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Update" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
Reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Update" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
Reg add "HKLM\SOFTWARE\Microsoft\PolicyManager\default\Update\ExcludeWUDriversInQualityUpdate" /v "value" /t REG_DWORD /d "0" /f >NUL 2>&1

Reg add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1
Reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v "ExcludeWUDriversInQualityUpdate" /t REG_DWORD /d "0" /f >NUL 2>&1

REM For x64 systems
IF /I "%OSARCH%"=="x64" (
reg delete "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Device Metadata" /v "PreventDeviceMetadataFromNetwork" /f >NUL 2>&1
reg delete "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DriverSearching" /v "DontPromptForWindowsUpdate" /f >NUL 2>&1
reg delete "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DriverSearching" /v "DontSearchWindowsUpdate" /f >NUL 2>&1
reg add "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DriverSearching" /v "DriverUpdateWizardWuSearchEnabled" /t REG_DWORD /d "1" /f >NUL 2>&1
reg add "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DriverSearching" /v "SearchOrderConfig" /t REG_DWORD /d "2" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\WindowsUpdate" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1
Reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\WindowsUpdate\UX\Settings" /v "ExcludeWUDriversInQualityUpdate" /f >NUL 2>&1
)

sc config DsmSvc start= auto >NUL 2>&1

echo.
echo Done. Reboot Required.

:Finished
TIMEOUT /T 5 >NUL 2>&1
exit

:IsAdmin
Reg query "HKU\S-1-5-19\Environment"
If Not %ERRORLEVEL% EQU 0 (
 Cls
 echo.
 Echo You must have administrator rights to continue...
 echo.
 Pause
 Exit
)
