Skip to content

Commit

Permalink
Addition of CPUTweaks as PowerShell & Fix Lil Bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Teramanbr committed Dec 20, 2022
1 parent 26ff598 commit 7e64e0d
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 4 deletions.
98 changes: 98 additions & 0 deletions src/CPUTweaks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
$CoreCount = Get-CimInstance -ClassName 'Win32_Processor' `
| Measure-Object -Property 'NumberOfCores' -Sum | Select-Object -ExpandProperty Sum

$LogicalProcessors = Get-CimInstance -ClassName 'Win32_Processor' `
| Measure-Object -Property 'NumberOfLogicalProcessors' -Sum | Select-Object -ExpandProperty Sum

$c = (reg query "HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") | Where-Object {$PSItem -Like "HKEY_*"} | Select-Object -First 1

If ($CoreCount -eq 2) {
Write-Output 'Only 2 cores' | Out-File -FilePath C:\TT\CoreInfo\INCompatibleCoreCount.txt
} Else {
Write-Output 'Seems to match the necessary' | Out-File -FilePath C:\TT\CoreInfo\CompatibleCoreCount.txt
}

# Backup
reg export "$c" "C:\TT\TTRevert\ognic.reg" /y *>$null
# Basics
reg add "$c" /v "MIMOPowerSaveMode" /t REG_SZ /d "3" /f *>$null
reg add "$c" /v "PowerSavingMode" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "EnableGreenEthernet" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*EEE" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*IPSecOffloadV1IPv4" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*IPSecOffloadV2IPv4" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*IPSecOffloadV2" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*RscIPv4" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*RscIPv6" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*PMNSOffload" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*PMARPOffload" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*JumboPacket" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "EnableConnectedPowerGating" /t REG_DWORD /d "0" /f *>$null
reg add "$c" /v "EnableDynamicPowerGating" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "EnableSavePowerNow" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "*FlowControl" /t REG_SZ /d "0" /f *>$null
# Power Saving Options
reg add "$c" /v "*NicAutoPowerSaver" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "ULPMode" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "EnablePME" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "AlternateSemaphoreDelay" /t REG_SZ /d "0" /f *>$null
reg add "$c" /v "AutoPowerSaveModeEnabled" /t REG_SZ /d "0" /f *>$null
# RSS
reg add "$c" /v "*NumRssQueues" /t REG_SZ /d "2" /f *>$null

If ($CoreCount -gt 4) {
$i = (wmic path Win32_VideoController get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "3" /f *>$null
Reg delete "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /f *>$null
$i = (wmic path Win32_NetworkAdapter get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "3" /f *>$null
Reg delete "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /f *>$null
} Else {
Write-Output 'Não tem os Requesitos, não são 4 núcleos' | Out-File -FilePath C:\TT\CoreInfo\NotEqualTo4.txt
}

If ($CoreCount -ge 4) {
$c = (reg query "HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") | Where-Object {$PSItem -Like "HKEY_*"} | Select-Object -First 1
reg add "$c" /v "*RssBaseProcNumber" /t REG_SZ /d "2" /f *>$null
reg add "$c" /v "*RssMaxProcNumber" /t REG_SZ /d "3" /f *>$null
} Else {
$c = (reg query "HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") | Where-Object {$PSItem -Like "HKEY_*"} | Select-Object -First 1
reg delete "$c" /v "*RssBaseProcNumber" /f *>$null
reg delete "$c" /v "*RssMaxProcNumber" /f *>$null
Write-Output 'Não tem os Requesitos, menos que 4 núcleos' | Out-File -FilePath C:\TT\CoreInfo\LessThan4.txt
}

If ($CoreCount -ge 6) {
$c = (reg query "HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") | Where-Object {$PSItem -Like "HKEY_*"} | Select-Object -First 1
reg add "$c" /v "*RssBaseProcNumber" /t REG_SZ /d "4" /f *>$null
reg add "$c" /v "*RssMaxProcNumber" /t REG_SZ /d "5" /f *>$null
} Else {
Write-Output 'Não tem os Requesitos, menos que 6 núcleos' | Out-File -FilePath C:\TT\CoreInfo\LessThan6.txt
}

If ($LogicalProcessors -gt $CoreCount) {
# HyperThreading is Enabled.
$i = (wmic path Win32_USBController get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "C0" /f *>$null
$i = (wmic path Win32_VideoController get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "C0" /f *>$null
$i = (wmic path Win32_NetworkAdapter get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "30" /f *>$null
Write-Output 'HyperThreading está Habilitado'
} Else {
# HyperThreading is Disabled.
$i = (wmic path Win32_USBController get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "08" /f *>$null
$i = (wmic path Win32_VideoController get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "02" /f *>$null
$i = (wmic path Win32_NetworkAdapter get PNPDeviceID) | Where-Object {$PSItem -Like "PCI\*"} | Select-Object -First 1
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "DevicePolicy" /t REG_DWORD /d "4" /f *>$null
reg add "HKLM\System\CurrentControlSet\Enum\$($i.Trim(' '))\Device Parameters\Interrupt Management\Affinity Policy" /v "AssignmentSetOverride" /t REG_BINARY /d "0" /f *>$null
Write-Output 'HyperThreading não está habilitado' | Out-File -FilePath C:\TT\CoreLogs.txt
}
exit
7 changes: 3 additions & 4 deletions src/Terabyte Tweaker.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@echo off
@title Terabyte Tweaker
SetLocal EnableDelayedExpansion
mkdir C:\TT\ >nul 2>&1
mkdir C:\TT\ >nul 2>&1 & mkdir C:\TT\CoreInfo\ >nul 2>&1
mkdir "%SystemDrive%\TT\TTRevert\" >nul 2>&1
set load=
set/a loadnum=5
setlocal
Expand Down Expand Up @@ -142,9 +143,8 @@ cls && ECHO This is not a valid option, please try again. && pause && goto retry


cls
%COL%[92m
echo.
echo ##############################
echo %COL%[92m##############################
echo %COL%[33mSettings%COL%[92m
echo ##############################
echo.
Expand Down Expand Up @@ -563,7 +563,6 @@ if %NumberOfLogicalProcessors% gtr %NumberOfCores% (
) >nul 2>&1
:finalcpu
for /f %%c in ('Reg query "HKLM\System\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}" /s /f "%%b" /d ^| findstr /C:"HKEY"') do (
mkdir "%SystemDrive%\TT\TTRevert\" >nul 2>&1
Reg export "%%c" "%SystemDrive%\TT\TTRevert\ognic.reg" /y >nul 2>&1
Reg add "%%c" /v "MIMOPowerSaveMode" /t REG_SZ /d "3" /f >nul 2>&1
Reg add "%%c" /v "PowerSavingMode" /t REG_SZ /d "0" /f >nul 2>&1
Expand Down

0 comments on commit 7e64e0d

Please sign in to comment.