This batch script is designed to perform several network-related optimizations...

July 3, 2025 at 08:48 AM

@echo off :: Ensure admin privileges NET SESSION >NUL 2>&1 IF %ERRORLEVEL% NEQ 0 ( ECHO Requesting administrative privileges... powershell -Command "Start-Process '%~f0' -Verb runAs" EXIT /B ) :: Detect active network adapter GUID FOR /F "tokens=3 delims={}" %%G IN ('reg query "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" /s ^| findstr /i "DhcpIPAddress"') DO SET NetGUID=%%G :: Write registry settings to a temp file SET "regfile=%temp%\network_opt.reg" > "%regfile%" ( echo Windows Registry Editor Version 5.00 echo. echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{%NetGUID%}] echo "TcpAckFrequency"=dword:00000001 echo "TCPNoDelay"=dword:00000001 echo. echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] echo "Tcp1323Opts"=dword:00000001 echo "DefaultTTL"=dword:00000040 echo "EnablePMTUBHDetect"=dword:00000000 echo "EnablePMTUDiscovery"=dword:00000001 echo "SackOpts"=dword:00000001 echo "TcpMaxDupAcks"=dword:00000002 echo "TcpWindowSize"=dword:0005ae4c echo "EnableTCPA"=dword:00000000 echo "DisableTaskOffload"=dword:00000001 echo "MaxUserPort"=dword:0000fffe echo "TcpTimedWaitDelay"=dword:0000001e echo "KeepAliveTime"=dword:0001d4c0 echo. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Psched] echo "NonBestEffortLimit"=dword:00000000 echo. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile] echo "NetworkThrottlingIndex"=dword:ffffffff echo "SystemResponsiveness"=dword:00000000 echo. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games] echo "Priority"=dword:00000006 echo "Scheduling Category"="High" echo "SFIO Priority"="High" echo. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization] echo "DODownloadMode"=dword:00000000 echo. echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters] echo "MaxCacheTtl"=dword:00015180 echo "MaxNegativeCacheTtl"=dword:0000001e echo "MaxSOACacheEntryTtlLimit"=dword:00015180 ) :: Apply the registry tweaks regedit /s "%regfile%" :: Flush DNS, reset IP and Winsock ipconfig /flushdns netsh int ip reset >nul netsh winsock reset >nul :: Cleanup del "%regfile%" >nul echo. echo ✅ Network optimization applied successfully. echo 🔁 Please restart your PC for all changes to take full effect. pause

This batch script is designed to perform several network-related optimizations by modifying Windows Registry settings and flushing network configurations. Here's a step-by-step explanation of what it does:

1. Ensure Administrative Privileges:

  • The script checks if it is running with admin privileges by attempting to run NET SESSION. If not, it uses PowerShell to re-launch itself with administrative rights (-Verb runAs).

2. Detect Active Network Adapter's GUID:

  • It uses the reg query command to find the GUID (Globally Unique Identifier) of the currently active network adapter by looking for entries with a DhcpIPAddress key in the registry.

3. Write Registry Tweaks to a .reg File:

  • A temporary .reg file is created in the system's %temp% directory. This file contains multiple registry tweaks targeting network, TCP/IP protocol, QoS (Quality of Service), and performance optimizations. Here's what the key tweaks do:
    • Network Adapter-Specific (via Adapter GUID):
      • Enable settings like TcpAckFrequency and TCPNoDelay, which may reduce TCP latency.
    • Global TCP Settings (HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters):
      • Modify parameters like TCP window size, delayed acknowledgment behavior, and packet management.
    • QoS Priority (HKLM\SOFTWARE\Policies\Microsoft\Windows\Psched):
      • Disable the non-best-effort bandwidth limit (e.g., reservable bandwidth).
    • Multimedia Settings:
      • Adjust settings like NetworkThrottlingIndex (disabling network throttling) and SystemResponsiveness to improve performance for gaming or multimedia tasks.
    • DNS Caching (HKLM\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters):
      • Modify DNS cache settings like maximum Time-To-Live (TTL) for cached entries.

4. Apply Registry Settings:

  • The .reg file is silently imported into the registry using regedit /s.

5. Flush and Reset Network Configuration:

  • The script flushes the DNS resolver cache (ipconfig /flushdns).
  • It resets IP stack settings (netsh int ip reset) and the Winsock catalog (netsh winsock reset).

6. Cleanup:

  • Deletes the temporary .reg file created earlier to keep the system clean.

7. Notify and Prompt Restart:

  • It prints a success message and advises the user to restart their PC to apply all changes.

Purpose:

The script is likely intended to lower network latency, optimize TCP settings, and improve gaming or multimedia performance. However, users should exercise caution when running scripts like this because modifying the registry incorrectly can lead to system issues.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node