Share via

Disable Wi-Fi and Trigger a One-Time Safe Boot (No Loop)

Dienow3xw 0 Reputation points
2026-06-03T01:52:54.68+00:00

I need a command line .bat file that will:

  • Disable wifi at the user settings level (basically turn off the setting as if you opened task bar and clicked it)
  • Enable safe mode for a ONE TIME reboot that will not carry over on the next restart from the safe mode interface.

I am sick and tired of running into brick walls with safe mode. Every way to boot into it just forcibly locks you in safe mode until you undo what you did to get in. Safe mode isn't just for security, it's for maintenance as well, and those of us doing maintenance need a way to easily automate this when we're constantly back and forth dealing with drivers instead of having to open and close a program several times to get what you need.

Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Most helpful
  1. Taki Ly (WICLOUD CORPORATION) 2,225 Reputation points Microsoft External Staff Moderator
    2026-06-03T03:45:16.4533333+00:00

    Hello @Dienow3xw ,

    I read your post, and it sounds like you've been dealing with the standard safe mode loop. You might be able to achieve what you're looking for by using a batch script that combines a PowerShell command for the Wi-Fi radio and the bcdedit /bootsequence flag for a one-time boot.

    This approach creates a temporary boot copy, sets it to safe mode, and tells the boot manager to use it only for the very next restart. Once you restart from safe mode, it should naturally revert to your normal Windows boot.

    I suggest trying the following .bat script. Note that it will request Administrator privileges since bcdedit requires them.

    @echo off
    :: Check for Administrator privileges
    NET SESSION >nul 2>&1
    if %errorLevel% neq 0 (
        powershell -Command "Start-Process '%~dpnx0' -Verb RunAs"
        exit /b
    )
    :: 1. Attempt to disable Wi-Fi radio (similar to using the taskbar toggle)
    powershell -Command "Get-NetAdapterRadio | Where-Object { $_.RadioType -eq 'WiFi' } | Set-NetAdapterRadio -WiFiState Off"
    :: 2. Create a temporary boot entry for Safe Mode
    for /f "tokens=3" %%a in ('bcdedit /copy {current} /d "One-Time Safe Mode"') do set TEMPGUID=%%a
    :: 3. Try to set the new entry to safe mode and configure it for a one-time boot sequence
    if defined TEMPGUID (
        bcdedit /set %TEMPGUID% safeboot minimal >nul
        bcdedit /bootsequence %TEMPGUID% >nul
        echo It looks like the setup was successful. You should enter Safe Mode on the next restart.
    ) else (
        echo I couldn't create the boot entry. You may want to check your bcdedit configuration.
    )
    pause
    

    For reference, I recommend checking out these official documentation pages:

    Please testing this updated version on a secondary machine first, just to verify it safely handles both the radio state and the reboot cycle in your specific environment. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.

    Thank you.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.