Skip to content

Commit

Permalink
feat: update finalize.cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyueta committed Oct 21, 2023
1 parent ca7da6e commit 9509820
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/playbook/Executables/FINALIZE.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ setlocal EnableDelayedExpansion

:: Enable MSI mode on USB, GPU, Audio, SATA controllers, disk drives and network adapters
:: Deleting DevicePriority sets the priority to undefined
for %%a in (
Win32_IDEController,
Win32_NetworkAdapter,
Win32_PnPEntity,
Win32_SoundDevice,
Win32_USBController,
Win32_VideoController,
) do (
if "%%a" == "Win32_PnPEntity" (
for %%a in ("CIM_NetworkAdapter", "CIM_USBController", "CIM_VideoController" "Win32_IDEController", "Win32_PnPEntity", "Win32_SoundDevice") do (
if "%%~a" == "Win32_PnPEntity" (
for /f "tokens=*" %%b in ('PowerShell -NoP -C "Get-WmiObject -Class Win32_PnPEntity | Where-Object {($_.PNPClass -eq 'SCSIAdapter') -or ($_.Caption -like '*High Definition Audio*')} | Where-Object { $_.PNPDeviceID -like 'PCI\VEN_*' } | Select-Object -ExpandProperty DeviceID"') do (
reg add "HKLM\SYSTEM\CurrentControlSet\Enum\%%b\Device Parameters\Interrupt Management\MessageSignaledInterruptProperties" /v "MSISupported" /t REG_DWORD /d "1" /f > nul
reg delete "HKLM\SYSTEM\CurrentControlSet\Enum\%%b\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePriority" /f > nul 2>&1
Expand All @@ -27,19 +20,15 @@ for %%a in (
)

:: If a virtual machine is used, set network adapter to normal priority as Undefined may break internet connection
wmic computersystem get manufacturer /format:value | findstr /i /c:VMWare && (
for /f %%a in ('wmic path Win32_NetworkAdapter get PNPDeviceID ^| findstr /l "PCI\VEN_"') do (
reg add "HKLM\SYSTEM\CurrentControlSet\Enum\%%a\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePriority" /t REG_DWORD /d "2" /f > nul
for %%a in ("hvm" "hyper" "innotek" "kvm" "parallel" "qemu" "virtual" "xen" "vmware") do (
wmic computersystem get manufacturer /format:value | findstr /i /c:%%~a && (
for /f %%b in ('wmic path CIM_NetworkAdapter get PNPDeviceID ^| findstr /l "PCI\VEN_"') do (
reg add "HKLM\SYSTEM\CurrentControlSet\Enum\%%b\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePriority" /t REG_DWORD /d "2" /f > nul
)
)
)

:: Miscellaneous

:: Disable DMA remapping
:: https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/enabling-dma-remapping-for-device-drivers
for /f %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Services" /s /f "DmaRemappingCompatible" ^| find /i "Services\" ') do (
reg add "%%a" /v "DmaRemappingCompatible" /t REG_DWORD /d "0" /f > nul
)
:: Network Configuration

:: Disable NetBios over tcp/ip
:: Works only when services are enabled
Expand Down Expand Up @@ -109,8 +98,6 @@ for %%a in (
"Node"
"NSOffloadEnable"
"PacketCoalescing"
rem Offload "PMARPOffload"
rem Offload "PMNSOffload"
"PMWiFiRekeyOffload"
"PowerDownPll"
"PowerSaveMode"
Expand Down Expand Up @@ -143,6 +130,14 @@ for %%a in (
)
)

:: Miscellaneous

:: Disable Direct Memory Access remapping
:: https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/enabling-dma-remapping-for-device-drivers
for /f %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Services" /s /f "DmaRemappingCompatible" ^| find /i "Services\" ') do (
reg add "%%a" /v "DmaRemappingCompatible" /t REG_DWORD /d "0" /f > nul
)

:: Hide unnecessary items from the 'Send To' context menu
for %%a in (
"Documents.mydocs"
Expand Down

0 comments on commit 9509820

Please sign in to comment.