πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.os.windows-11
Article #118

Re: Tip: full network reset

#118
From: Maria Sophia
Date: Sat, 10 Oct 2026 17:47
161 lines
6474 bytes
> I was remoted into a customer and did something stupid.
> 
> What did I do??? I ain't tellin'! 😁
> 
> Needless to say, I had to coach the customer over the
> phone through a full network reset:
> 
> 
> <Network.Reset.Full.Nuke.txt>
> Windows 10/11 Full Network Reset:
> 
> GUI:
> --> Click Start
>     --> Settings.
>       --> Network & Internet.
> 
>      Windows 11: Click Advanced network settings β†’ Network reset.
>      Windows 10: Click Status β†’ Network reset.
> 
>          --> Click Reset now.
>            --> Confirm Yes if prompted.
>                The PC will restart automatically (or do a manual restart).
> 
> 
> Admin CMD:
>     netsh int ip reset
>     netsh winsock reset
>     ipconfig /flushdns
>     shutdown /r /f /t 00
> 
> Note: Save any open work before running the final command;
>        /f force-closes applications.
> </Network.Reset.Full.Nuke.txt>
> 
> 
> HTH someone else,
> -T

Whenever I screw up the network, I run this to reset Wi-Fi/Ethernet.

  @echo off
  REM This is v1p6 of C:\data\sys\batch\netconnect.bat 
  REM Resets Wi-Fi to a consistent state after unexpected loss
  REM v1p0  20251029
  REM  elevates to admin 
  REM  toggles Wi-Fi to put it into a consistent state after reboot
  REM  then connects to a given named SSID 
  REM v1p1  20251101
  REM  added conditional checks and retries
  REM v1p2  20251102
  REM  added loop to verify State/SSID and retry until truly connected
  REM v1p3 20251213
  REM  added immediate Wi-Fi environment scan after successful connection
  REM v1p4 20251213 
  REM  outputs and overwrites log of the wrong name (no timestamp) 
  REM  in the wrong directory (it should be in the log directory!)
  REM v1p5 20251213 
  REM  outputs timestamped log file in the log directory
  REM v1p6 20251213
  REM  WIP added logging of nearby cached access points after connection
  
  :: --- Elevate to admin if not already ---
  >nul 2>&1 net session
  if %errorlevel% neq 0 (
      echo Requesting administrative privileges...
      powershell -Command "Start-Process '%~f0' -Verb RunAs"
      exit /b
  )
  
  :: Use "netsh interface show interface" to get adapter name
  set adapter=Wi-Fi
  :: Assumption is that the ssid:password has already been saved
  set ssid=nordstrom.office_nomap
  
  :: The saved SSID profile is used for credentials.
  echo [%date% %time%] Toggling Wi-Fi adapter...
  netsh interface show interface name=%adapter%
  
  REM Disable the adapter (to set to a consistent state)
  netsh interface set interface name=%adapter% admin=disable
  timeout /t 5 >nul
  
  REM Enable the adapter (to set to the desired state)
  netsh interface set interface name=%adapter% admin=enable
  timeout /t 10 >nul
  
  echo Attempting to connect to %ssid%...
  
  REM Connect to the specified SSID after adapter is fully enabled
  powershell -Command "Enable-NetAdapter -Name '%adapter%' -Confirm:$false"
  timeout /t 5 >nul
  
  REM Added loop to verify State/SSID and retry until truly connected
  set retries=3
  :retry
  echo Connecting to %ssid%...
  netsh wlan connect name=%ssid%
  timeout /t 5 >nul
  
  for /f "tokens=2 delims=:" %%A in ('netsh wlan show interfaces ^| findstr /C:"State"') do (
      set state=%%A
  )
  for /f "tokens=2 delims=:" %%A in ('netsh wlan show interfaces ^| findstr /C:"SSID" ^| findstr /V "BSSID"') do (
      set currentSSID=%%A
  )
  
  set "state=%state: =%"
  set "currentSSID=%currentSSID: =%"
  
  REM Define log directory and ensure it exists
  set "logdir=C:\data\sys\log"
  if not exist "%logdir%" mkdir "%logdir%"
  
  REM Build timestamp for filename using WMIC (locale-independent)
  for /f %%A in ('wmic os get localdatetime ^| find "."') do set dt=%%A
  set "ts=%dt:~0,8%_%dt:~8,6%"
  
  REM Define logfile path with timestamp
  set "logfile=%logdir%\wifiscan_%ts%.log"
  
  REM Always create logfile entry, regardless of connection state
  echo === Run at %date% %time% === >> "%logfile%"
  echo Target SSID: %ssid% >> "%logfile%"
  echo State=[%state%] CurrentSSID=[%currentSSID%] >> "%logfile%"
  
  if /I "%state: =%"=="connected" (
      echo Connected (state=connected). Target SSID: %ssid%
      >> "%logfile%" echo Nearby Wi-Fi environment after connect:
      netsh wlan show networks mode=bssid >> "%logfile%"
      echo Wi-Fi environment snapshot saved to %logfile%
      goto done
  ) else (
      set /a retries-=1
      if %retries% gtr 0 (
          echo Not connected yet. Retrying...
          timeout /t 5 >nul
          goto retry
      ) else (
          echo Connection failed after multiple attempts.
          >> "%logfile%" echo Connection failed after multiple attempts.
      )
  )
  
  
  :done
  
  echo [%date% %time%] Done. Check your connection status.
  echo Final adapter status:
  netsh interface show interface name=%adapter%
  netsh wlan show interfaces
  
  REM Show the log contents in the console
  type "%logfile%"
  
  REM Open the log file with the default associated editor (gVim in your setup)
  start "" "%logfile%"
  
  pause
  :: end of C:\data\sys\batch\netconnect.bat
  
Technical Details
Message-ID: <11adtmo$q4e$1@nnrp.usenet.blueworldhosting.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED.public-nat-12.vpngate.v4.open.ad.jp!not-for-mail
References: <11ad9na$1mp2o$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nnrp.usenet.blueworldhosting.com!.POSTED.public-nat-12.vpngate.v4.open.ad.jp!not-for-mail
From: Maria Sophia <mariasophia@comprehension.com>
Newsgroups: alt.comp.os.windows-11,alt.comp.os.windows-10
Subject: Re: Tip: full network reset
Date: Sat, 10 Oct 2026 10:47:07 -0700
Organization: BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID: <11adtmo$q4e$1@nnrp.usenet.blueworldhosting.com>
References: <11ad9na$1mp2o$1@dont-email.me>
Reply-To: pusvul@getTjewytR4so+mqe2.invalid
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 10 Oct 2026 17:47:10 -0000 (UTC)
Injection-Info: nnrp.usenet.blueworldhosting.com; posting-account="l//KxG3Ge2LojWvwJg0Igv8F0ChK8RUC9RtOxMPUo3U"; posting-host="Dg8vEhE1wZBDJOwXTSEKAoRS4PU2oXroEpl9dza6STY";
	logging-data="26766"; mail-complaints-to="usenet@blueworldhosting.com"
User-Agent: Mojibake 1p3
Cancel-Lock: sha1:deAJRqQu++tk8mYpFK23yl1W89k= sha256:S9H/YU5r0c1kUeqdIBN79F/ZORlBVRk8lOLqS0q43MU=
	sha1:iT4g08042uKKp+e4Tes7Rho1Gv0= sha256:PHzt4sWU3jJBt8NQxQ9muf/3jOvY6pQvOisc4dVRWBs=
Content-Language: en-GB