From 6625cc6add08d2dc6bd9e59a932ea71d647bde50 Mon Sep 17 00:00:00 2001 From: M1HA1 <67576278+M1HA15@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:17:29 +0300 Subject: [PATCH] Update NSR.bat --- NSR.bat | 283 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 176 insertions(+), 107 deletions(-) diff --git a/NSR.bat b/NSR.bat index 8c00afa..9d19c9b 100644 --- a/NSR.bat +++ b/NSR.bat @@ -1,10 +1,11 @@ @echo off cls +title NSR (0.7) where powershell >nul 2>&1 if %errorlevel% neq 0 ( color 0C - echo PowerShell is not installed. Please install PowerShell and run the script again! + echo PowerShell is Not Installed. Please Install PowerShell and Run the Script Again! echo. pause exit @@ -14,27 +15,48 @@ for /f "delims=" %%V in ('powershell -Command "$PSVersionTable.PSVersion.Major.T >nul 2>&1 net session || ( color 0C - echo This script requires administrator privileges. - echo Please run the script as an administrator! - echo. - echo PowerShell version: %PSVersion% + echo This Script equires Administrator Privileges. + echo Please Run the Script as an Administrator! echo. + echo PowerShell Version: %PSVersion% echo. pause exit ) + +:mainMenu +cls +echo =============================================================================== +echo NSR (0.7) +echo PowerShell Version: %PSVersion% +echo Running with Administrator Privileges +echo =============================================================================== +echo. +echo. +echo. +echo [1] Network Maintenance (Recommended) +echo [2] Change DNS Provider +echo [3] Ping DNS Provider +echo [4] Info About Your PC +echo [5] Info About Script +echo [6] Exit +echo. +set /p "choice=Enter your choice (1-6): " +if "%choice%"=="1" goto :networkMaintenance +if "%choice%"=="2" goto :changeDNS +if "%choice%"=="3" goto :pingDNSMenu +if "%choice%"=="4" goto :infoPC +if "%choice%"=="5" goto :infoScript +if "%choice%"=="6" goto :exitMenu +goto :mainMenu + +:networkMaintenance +cls echo --------------------------------------------------------------------- -echo NSR (0.6) -echo. -echo Warning: The script is running with administrator privileges! -echo Warning: This version may contain bugs or issues! -echo PowerShell Version: %PSVersion% +echo Network Maintenance echo --------------------------------------------------------------------- echo. -echo. -timeout /nobreak /t 3 > nul - echo [1] Flushing DNS Cache... ipconfig /flushdns echo. @@ -54,36 +76,35 @@ echo. echo [5] Resetting Winsock... netsh winsock reset echo. - -timeout /nobreak /t 2 > nul echo. echo. -:menuDNS -echo [6] DNS Provider: -echo [1] Recommended DNS Providers -echo [2] Test Recommended DNS Providers -echo [3] Input your DNS Provider -echo [4] Test your DNS Provider -echo [5] Skip +echo Maintenance Completed Successfully! echo. +pause +goto :mainMenu -set /p "dnsChoice=Enter your choice (1-5): " +:changeDNS +cls +echo --------------------------------------------------------------------- +echo Change DNS Provider +echo --------------------------------------------------------------------- echo. - -if "%dnsChoice%"=="" goto :menuDNS - -if "%dnsChoice%"=="1" goto :recommendedDNS -if "%dnsChoice%"=="2" goto :pingDNS -if "%dnsChoice%"=="3" goto :customDNS -if "%dnsChoice%"=="4" goto :pingDNS2 -if "%dnsChoice%"=="5" goto :skipDNS - -echo Invalid choice! Returning to the DNS menu... +echo [1] Recommended DNS Providers +echo [2] Enter Your Provider +echo [3] Exit echo. -goto :menuDNS +set /p "dnsChoice=Enter your choice (1-3): " +if "%dnsChoice%"=="1" goto :recommendedDNS +if "%dnsChoice%"=="2" goto :customDNS +if "%dnsChoice%"=="3" goto :mainMenu +goto :changeDNS :recommendedDNS +cls +echo --------------------------------------------------------------------- +echo Recommended DNS Providers +echo --------------------------------------------------------------------- echo Choose a Recommended DNS Provider: echo [1] Cloudflare (1.1.1.1) echo [2] Cisco Umbrella (208.67.222.222) @@ -91,107 +112,74 @@ echo [3] GCore (95.85.95.85) echo [4] Quad9 (9.9.9.9) echo [5] Google (8.8.8.8) echo. +echo Note: DNS Providers are listed based on performance data obtained from DNSPerf. Please be aware that actual performance may vary depending on your location and network conditions. +echo. set /p "recommendedDNSChoice=Enter your choice (1-5): " echo. if "%recommendedDNSChoice%"=="1" ( set DNS_IP=1.1.1.1 set DNS_Secondary_IP=1.0.0.1 - set DNS_IPv6=2606:4700:4700::1111 + set DNS_IPv6=2606:4700:4700::1111 set DNS_Secondary_IPv6=2606:4700:4700::1001 ) else if "%recommendedDNSChoice%"=="2" ( set DNS_IP=208.67.222.222 set DNS_Secondary_IP=208.67.220.220 - set DNS_IPv6=2620:119:35::35 + set DNS_IPv6=2620:119:35::35 set DNS_Secondary_IPv6=2620:119:53::53 ) else if "%recommendedDNSChoice%"=="3" ( set DNS_IP=95.85.95.85 set DNS_Secondary_IP=2.56.220.2 - set DNS_IPv6=2a03:90c0:999d::1 + set DNS_IPv6=2a03:90c0:999d::1 set DNS_Secondary_IPv6=2a03:90c0:9992::1 ) else if "%recommendedDNSChoice%"=="4" ( set DNS_IP=9.9.9.9 set DNS_Secondary_IP=149.112.112.112 - set DNS_IPv6=2620:fe::fe + set DNS_IPv6=2620:fe::fe set DNS_Secondary_IPv6=2620:fe::9 ) else if "%recommendedDNSChoice%"=="5" ( set DNS_IP=8.8.8.8 set DNS_Secondary_IP=8.8.4.4 - set DNS_IPv6=2001:4860:4860::8888 + set DNS_IPv6=2001:4860:4860::8888 set DNS_Secondary_IPv6=2001:4860:4860::8844 ) else ( - echo. + echo. echo You have chosen an invalid option! Please select a correct option... + pause goto :recommendedDNS - echo. ) goto :setDNS -:pingDNS -echo Commencing Recommended DNS Providers Evaluation... -echo Please be aware that this analysis may require some time to complete. -echo. -echo Warning: This thorough evaluation includes the transmission of 20 packets, with each packet carrying 32 bytes of data, to every DNS Providers! -echo. -echo. -for %%i in (1.1.1.1 208.67.222.222 95.85.95.85 9.9.9.9 8.8.8.8) do ( - for /f "tokens=*" %%a in ('ping -n 20 -w 1000 %%i ^| find "Minimum"') do ( - echo Results for %%i: - echo %%a - echo. - ) -) -echo Testing complete! Consider the DNS Provider with the lowest ping times for optimal network performance. -echo. -goto :menuDNS - -:pingDNS2 -set /p "customDNS=Enter your DNS Provider: " -echo. - -echo Commencing DNS Provider Evaluation... -echo Please be aware that this analysis may require some time to complete. -echo. -echo Warning: This thorough evaluation includes the transmission of 20 packets, with each packet carrying 32 bytes of data, to the specified DNS Provider! -echo. -echo. - -for /f "tokens=*" %%a in ('ping -n 20 -w 1000 %customDNS% ^| find "Minimum"') do ( - echo Results for %customDNS%: - echo %%a - echo. -) - -echo Testing complete! Optimal DNS Provider based on lowest ping times. -echo. -goto :menuDNS - :customDNS -set /p "visitDNSPerf=Do you want to visit DNSPerf to choose a DNS Provider? (Y/N): " -if /i "%visitDNSPerf%"=="Y" ( - start "" "https://www.dnsperf.com/" -) +cls +echo --------------------------------------------------------------------- +echo Enter Your DNS Provider +echo --------------------------------------------------------------------- echo. -echo Please input the IPv4 and IPv6 addresses of the selected DNS Provider! set /p "DNS_IP=Enter your Primary IPv4 DNS address: " set /p "DNS_Secondary_IP=Enter your Secondary IPv4 DNS address: " set /p "DNS_IPv6=Enter your Primary IPv6 DNS address: " set /p "DNS_Secondary_IPv6=Enter your Secondary IPv6 DNS address: " echo. -echo Please wait a moment while we configure the desired addresses for the selected DNS Provider... -echo. goto :setDNS -:skipDNS -echo Skipping DNS provider selection... -echo. -goto :setGitHub - :setDNS +cls +echo --------------------------------------------------------------------- +echo Setting DNS Provider +echo --------------------------------------------------------------------- +echo. +echo Setting IPv4 DNS... +timeout /nobreak /t 1 > nul if not "%DNS_IP%"=="" ( powershell -Command "& { Get-NetAdapter | ForEach-Object { try { Set-DnsClientServerAddress -InterfaceAlias $_.Name -ServerAddresses @('%DNS_IP%', '%DNS_Secondary_IP%') -ErrorAction Stop } catch { Write-Error $_ } } }" echo Primary IPv4 DNS set to %DNS_IP% echo Secondary IPv4 DNS set to %DNS_Secondary_IP% ) + +echo. + +echo Setting IPv6 DNS... +timeout /nobreak /t 1 > nul if not "%DNS_IPv6%"=="" ( powershell -Command "& { Get-NetAdapter | ForEach-Object { try { Set-DnsClientServerAddress -InterfaceAlias $_.Name -ServerAddresses @('%DNS_IPv6%', '%DNS_Secondary_IPv6%') -ErrorAction Stop } catch { Write-Error $_ } } }" echo Primary IPv6 DNS set to %DNS_IPv6% @@ -200,39 +188,120 @@ if not "%DNS_IPv6%"=="" ( echo. echo Successfully activated the selected DNS Provider! echo. +pause +goto :mainMenu + +:pingDNSMenu +cls +echo --------------------------------------------------------------------- +echo Ping DNS Provider +echo --------------------------------------------------------------------- +echo. +echo [1] Ping Recommended DNS Providers +echo [2] Ping Your DNS Provider +echo [3] Exit echo. +set /p "pingChoice=Enter your choice (1-3): " +if "%pingChoice%"=="1" goto :pingRecommendedDNS +if "%pingChoice%"=="2" goto :pingCustomDNS +if "%pingChoice%"=="3" goto :mainMenu +goto :pingDNSMenu -:setGitHub -set /p "skipCleany=Want to check out our other project? (Y/N): " -if /i "%skipCleany%"=="Y" ( +:pingRecommendedDNS +cls +echo --------------------------------------------------------------------- +echo Ping Recommended DNS Providers +echo --------------------------------------------------------------------- +echo. +echo Note: This sequence will take some time to complete as it performs Ping Tests on Recommended DNS Providers. Please be patient while the script is running... +echo. +echo. + +for %%i in (1.1.1.1 208.67.222.222 95.85.95.85 9.9.9.9 8.8.8.8) do ( + for /f "tokens=*" %%a in ('ping -n 30 -w 1000 %%i ^| find "Minimum"') do ( + echo Results for %%i: + echo %%a + echo. + ) +) +pause +goto :mainMenu + +:pingCustomDNS +cls +set /p "customDNS=Enter your DNS Provider: " +echo. +echo Note: This sequence will take some time to complete as it performs Ping Tests on your Custom DNS Provider. Please be patient while the script is running... +echo. +echo. + +for /f "tokens=*" %%a in ('ping -n 30 -w 1000 %customDNS% ^| find "Minimum"') do ( + echo Results for %customDNS%: + echo %%a + echo. +) +echo. +pause +goto :mainMenu + +:infoPC +cls +echo --------------------------------------------------------------------- +echo Info About Your PC +echo --------------------------------------------------------------------- +echo. +systeminfo | more +pause +goto :mainMenu + +:infoScript +cls +set "betaVersion=Y(0.3)" +echo --------------------------------------------------------------------- +echo Info About Script +echo --------------------------------------------------------------------- +echo. +echo Script Name: NSR +echo Version: 0.7 +echo Author: M1HA15 +echo Beta Version: %betaVersion% +echo. +set /p "openGitHub=Do you want to open NSR GitHub Page? (Y/N): " +if /i "%openGitHub%"=="Y" ( + echo Opening default web browser... + start "" "https://github.com/M1HA15/Network-Settings-Reset" +) +echo. +echo. +set /p "openCleany=Do you want to check Cleany? (Y/N): " +if /i "%openCleany%"=="Y" ( echo Opening default web browser... start "" "https://github.com/M1HA15/Cleany" -) else if /i "%skipCleany%"=="N" ( - echo Skiping this section... - goto :setRestart -) else ( - echo You have chosen an invalid option! Please select a correct option... - echo. - goto :setGitHub ) - echo. +echo. +pause +goto :mainMenu -:setRestart +:exitMenu +echo. set /p "skipRestartChoice=Do you want to restart the computer now? (Y/N): " if /i "%skipRestartChoice%"=="Y" ( + echo. echo Thank you for utilizing the script! Your computer will restart shortly... - timeout /nobreak /t 4 > nul + timeout /nobreak /t 3 > nul shutdown /r /t 5 /f + echo. ) else if /i "%skipRestartChoice%"=="N" ( + echo. echo Thank you for utilizing the script! Please remember to restart your computer when convenient. echo Waiting for 5 seconds before closing the window... - timeout /nobreak /t 4 > nul + timeout /nobreak /t 5 > nul exit ) else ( echo You have chosen an invalid option! Please select a correct option... echo. - goto :setRestart + goto :mainMenu ) :eof