Created
November 12, 2025 14:47
-
-
Save Mehran1022mm/d23249741dc295dbf5feba015bb2d580 to your computer and use it in GitHub Desktop.
A Windows batch tool to backup, restore, and fix the NCSI internet connectivity check using a reliable Cloudflare probe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| title Microsoft NCSI Fix Tool | |
| color 0A | |
| setlocal enabledelayedexpansion | |
| :: =============================================================== | |
| :: Microsoft NCSI Fix Tool | |
| :: Purpose: Backup, Restore, and Fix Windows Network Connectivity Check | |
| :: Uses Cloudflare connectivity test (cp.cloudflare.com/generate_204) | |
| :: =============================================================== | |
| set "REG_PATH=HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" | |
| set "BACKUP_FILE=%~dp0NCSI_backup.txt" | |
| :menu | |
| cls | |
| echo =============================================================== | |
| echo Microsoft NCSI Internet Check Fix Tool | |
| echo =============================================================== | |
| echo. | |
| echo [1] Backup current NCSI settings | |
| echo [2] Apply Cloudflare probe fix | |
| echo [3] Restore from backup | |
| echo [4] Exit | |
| echo. | |
| set /p choice="Select an option (1-4): " | |
| if "%choice%"=="1" goto backup | |
| if "%choice%"=="2" goto apply | |
| if "%choice%"=="3" goto restore | |
| if "%choice%"=="4" exit | |
| goto menu | |
| :backup | |
| echo. | |
| echo [*] Backing up current NCSI registry values... | |
| echo --------------------------------------------------------------- > "%BACKUP_FILE%" | |
| for %%K in (ActiveWebProbeHost ActiveWebProbePath ActiveWebProbeContent ActiveDnsProbeHost ActiveDnsProbeContent EnableActiveProbing) do ( | |
| for /f "tokens=2,*" %%A in ('reg query "%REG_PATH%" /v %%K 2^>nul') do ( | |
| echo %%K=%%B>>"%BACKUP_FILE%" | |
| echo Saved %%K=%%B | |
| ) | |
| ) | |
| echo --------------------------------------------------------------- >> "%BACKUP_FILE%" | |
| echo [OK] Backup saved to "%BACKUP_FILE%" | |
| pause | |
| goto menu | |
| :apply | |
| echo. | |
| echo [*] Applying Cloudflare probe fix... | |
| reg add "%REG_PATH%" /v ActiveWebProbeHost /t REG_SZ /d "cp.cloudflare.com" /f >nul | |
| reg add "%REG_PATH%" /v ActiveWebProbePath /t REG_SZ /d "/generate_204" /f >nul | |
| reg add "%REG_PATH%" /v ActiveWebProbeContent /t REG_SZ /d "" /f >nul | |
| reg add "%REG_PATH%" /v ActiveDnsProbeHost /t REG_SZ /d "1.1.1.1" /f >nul | |
| reg add "%REG_PATH%" /v ActiveDnsProbeContent /t REG_SZ /d "" /f >nul | |
| reg add "%REG_PATH%" /v EnableActiveProbing /t REG_DWORD /d 1 /f >nul | |
| echo [OK] Cloudflare probe fix applied successfully! | |
| echo [INFO] Please restart your computer or run: | |
| echo net stop nlasvc && net start nlasvc | |
| pause | |
| goto menu | |
| :restore | |
| echo. | |
| if not exist "%BACKUP_FILE%" ( | |
| echo [ERROR] No backup file found: "%BACKUP_FILE%" | |
| pause | |
| goto menu | |
| ) | |
| echo [*] Restoring NCSI registry values from backup... | |
| for /f "usebackq tokens=1,2 delims==" %%A in ("%BACKUP_FILE%") do ( | |
| if not "%%A"=="" ( | |
| reg add "%REG_PATH%" /v %%A /d "%%B" /f >nul | |
| echo Restored %%A=%%B | |
| ) | |
| ) | |
| echo [OK] Restore complete. Please restart your computer. | |
| pause | |
| goto menu |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
*Remember to run the file as administrator.