Author Topic: Complete Network Reset without needing a Restart  (Read 11309 times)

0 Members and 1 Guest are viewing this topic.

Offline Rolemodel

  • Newbie
  • *
  • Join Date: Mar 2014
  • Posts: 13
  • Karma: 1
    • View Profile
Complete Network Reset without needing a Restart
« on: March 10, 2014, 10:29:00 AM »
I have created a batch file that creates a backup of any existing network settings and completely resets all the network caches and components I could find on the net. I am still experimenting with it and have found Windows Repair AIO to be very handy. I do not know if you could use some of my script? Although I have noticed a lot of the commands you already have used. The content of this script is compiled from various sources.

Windows 7
Code: [Select]
@ECHO off
TITLE Full Network Reset [Win 7]
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (shift & goto gotPrivileges) 
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B

:gotPrivileges
::::::::::::::::::::::::::::
:START

ECHO Please save and close everything before proceeding
Pause
ECHO Creating Backup...
MD %HomeDrive%\Backup\etc
MD %HomeDrive%\Backup\Registry
xcopy %windir%\system32\drivers\etc %HomeDrive%\Backup\etc /H /I /Y
Regedit /E %HomeDrive%\Backup\Registry\Registry.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\NetBt\Parameters %HomeDrive%\Backup\Registry\NetBT_Parameters.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters %HomeDrive%\Backup\Registry\LanmanServer_Parameters.reg
netsh -c interface dump > %HomeDrive%\Backup\IPBackup.txt
ipconfig /all >> %HomeDrive%\Backup\IPConfig.txt
netsh int ip show config >> %HomeDrive%\Backup\NetshConfig.txt
netsh int ip show addresses >> %HomeDrive%\Backup\Netsh.txt
netsh int ip show dnsservers >> %HomeDrive%\Backup\Netsh.txt
netsh ipsec static show all >> %HomeDrive%\Backup\IPSec.txt
nbtstat -n >> %HomeDrive%\Backup\nbtstat.txt
nbtstat -r >> %HomeDrive%\Backup\nbtstat.txt
whoami /all >> %HomeDrive%\Backup\UserDetails.txt
start %HomeDrive%\Backup\
cls
ECHO Backup Complete...
Pause

cls
ECHO Stopping Services...
net stop Mcx2Svc /y
net stop IPBusEnum /y
net stop HomeGroupProvider /y
net stop FDResPub /y
net stop fdPHost /y
net stop netprofm /y
net stop HomeGroupListener /y
net stop Browser /y
net stop LanmanServer /y
net stop WwanSvc /y
net stop NlaSvc /y
net stop WinHttpAutoProxySvc /y
net stop Dhcp /y
net stop Dnscache /y
net stop iphlpsvc /y
net stop SharedAccess /y
net stop Netman /y
net stop Browser /y
net stop Netlogon /y
net stop SessionEnv /y
net stop LanmanWorkstation /y
net stop nsi /y
net stop dot3svc /y
net stop Wlansvc /y
net stop EapHost /y
net stop KeyIso /y
net stop PolicyAgent /y
net stop lmhosts /y
net stop DPS /y
net stop EventSystem /y

cls
ECHO Resetting Network Environment...

pushd\windows\system32\drivers\etc
attrib -h -s -r hosts
ECHO 127.0.0.1 localhost>HOSTS
attrib +r +h +s hosts
popd

 ::If you can ping a remote computer IP but not the name this may be an outdated NetBIOS name resolution in the local NetBIOS name cache. Reset the cache and force the computer to retrieve remote computer name.
nbtstat -R
nbtstat -RR
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v NodeType /f
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v DhcpNodeType /f
REG ADD HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters /v Size /d 3 /f
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" /v LargeSystemCache /d 1 /f

 ::Reset the routing table
route /f

 ::Resets Winsock Catalog to a clean state. Restart computer after this one.
netsh winsock reset all
netsh winsock reset catalog

 ::Restores Windows Firewall with Advanced Security policy to the default policy.
netsh advfirewall reset

 :: Deletes all IP Sec Policies
netsh ipsec dynamic delete all

 ::Resets the BranchCache service. Flushes the local cache.
netsh branchcache reset

 ::Flushes ARP Cache
netsh int ip delete arpcache

 ::Resets TCP/IP and related components to a clean state. (IPv4 & IPv6)
netsh int ip reset all
netsh int ipv6 reset all

cls
ECHO Starting Services...
net start EventSystem /y
net start DPS /y
net start lmhosts /y
net start PolicyAgent /y
net start KeyIso /y
net start EapHost /y
net start Wlansvc /y
net start dot3svc /y
net start nsi /y
net start LanmanWorkstation /y
net start SessionEnv /y
net start Netlogon /y
net start Browser /y
net start Netman /y
net start SharedAccess /y
net start iphlpsvc /y
net start Dnscache /y
net start Dhcp /y
net start WinHttpAutoProxySvc /y
net start NlaSvc /y
net start WwanSvc /y
net start LanmanServer /y
net start Browser /y
net start HomeGroupListener /y
net start netprofm /y
net start fdPHost /y
net start FDResPub /y
net start HomeGroupProvider /y
net start IPBusEnum /y
net start Mcx2Svc /y

cls
ECHO Renew IP Settings...
::Release & Renew the IP Configuration & Flush DNS settings.
netsh interface ip set address "Local Area Connection" dhcp
ipconfig /release
ipconfig /flushdns
netsh interface ip set address "Local Area Connection" dhcp
ipconfig /renew
ipconfig /registerdns

cls
ECHO Operation Completed...
ECHO.
ECHO Reboot computer if network not accessible...
PAUSE
REM To restart PC afterwards enable the following command: shutdown -r -t 1

Windows XP
Code: [Select]
@ECHO OFF
TITLE Full Network Reset [Win XP]
::Network Reset Windows XP

ECHO Creating Backup...
MD %HomeDrive%\Backup\etc
MD %HomeDrive%\Backup\Registry
xcopy %windir%\system32\drivers\etc %HomeDrive%\Backup\etc /H /I /Y
Regedit /E %HomeDrive%\Backup\Registry\Registry.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\NetBt\Parameters %HomeDrive%\Backup\Registry\NetBT_Parameters.reg
REG EXPORT HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters %HomeDrive%\Backup\Registry\LanmanServer_Parameters.reg
netsh -c interface dump > %HomeDrive%\Backup\IPBackup.txt
ipconfig /all >> %HomeDrive%\Backup\IPConfig.txt
netsh int ip show config >> %HomeDrive%\Backup\NetshConfig.txt
netsh int ip show addresses >> %HomeDrive%\Backup\Netsh.txt
netsh int ip show dnsservers >> %HomeDrive%\Backup\Netsh.txt
nbtstat -n >> %HomeDrive%\Backup\nbtstat.txt
nbtstat -r >> %HomeDrive%\Backup\nbtstat.txt
start %HomeDrive%\Backup\
ECHO Backup Complete...
Pause

cls
ECHO Stopping Services...
:: Application Layer Gateway Service - Manual - No Dependencies
Net Stop ALG /Y
::Background Intelligent Transfer Service - Manual - No Dependencies
Net Stop BITS /Y
:: DHCP Client - Automatic - No Dependencies.
Net Stop DHCP /Y
::Distributed Link Tracking Client - Automatic - No Dependencies
Net Stop TrkWks /Y
::DNS CLient - Automatic - No Dependencies
Net Stop Dnscache /Y
::Indexing Service - Manual - No Dependencies
Net Stop CiSvc /Y
::IPSEC Services - Automatic - No Dependencies
Net Stop PolicyAgent /Y
::Network Location Awareness (NLA) - Manual - No Dependencies
Net Stop Nla /Y
::QoS RSVP - Manual - No Dependencies
Net Stop RSVP /Y
::Universal Plug and Play Device Host - Manual - No Dependencies
Net Stop upnphost /Y
::SSDP Discovery Service - Manual - Universal Plug & Play Device Host
Net Stop SSDPSRV /Y
::TCP/IP NetBIOS Helper - Automatic - No Dependencies
Net Stop LmHosts /Y
::Remote Access Auto Connection Manager - Manual - No Dependencies
Net Stop RasAuto /Y
::Remote Access Connection Manager - Manual - RasAuto
Net Stop RasMan /Y
::Telephony - Manual - RasAuto & RasMan
Net Stop TapiSrv /Y
::WebClient - Automatic - No Dependencies
Net Stop WebClient /Y
::Windows Firewall/Internet Connection Sharing (ICS) - Automatic - No Dependencies
Net Stop SharedAccess /Y
::Network Connections - Manual - Windows Firewall/Internet Connection Sharing.
Net Stop Netman /Y
::Wired AutoConfig - Manual - No Dependencies
Net Stop Dot3svc /Y
::Extensible Authentication Protocol Service - Manual - Wired Autoconfig
Net Stop EapHost /Y
::Wireless Zero Configuration - Automatic - No Dependencies
Net Stop WZCSVC /Y
::Alerter - Disabled - No Dependencies
Net Stop Alerter /Y
::Computer Browser - Automatic - No Dependencies.
Net Stop Browser /Y
::Server - Automatic - Computer Browser
Net Stop LanmanServer /Y
::Messenger - Disabled - No Dependencies
Net Stop Messenger /Y
::Net Logon - Manual - No Dependencies
Net Stop Netlogon /Y
::Remote Procedure Call (RPC) Locator - Manual - No Dependencies
Net Stop RpcLocator /Y
::Workstation - Automatic - Alerter, Computer Browser, Messenger, Net Logon, RPC Locator
Net Stop lanmanworkstation /Y

cls
ECHO Resetting Network Environment...

pushd\windows\system32\drivers\etc
attrib -h -s -r hosts
ECHO 127.0.0.1 localhost>HOSTS
attrib +r +h +s hosts
popd

 ::If you can ping a remote computer IP but not the name this may be an outdated NetBIOS name resolution in the local NetBIOS name cache. Reset the cache and force the computer to retrieve remote computer name.
nbtstat -R
nbtstat -RR
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v NodeType /f
REG DELETE HKLM\System\CurrentControlSet\Services\NetBt\Parameters /v DhcpNodeType /f
REG ADD HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters /v Size /d 3 /f
REG ADD "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" /v LargeSystemCache /d 1 /f

 ::Reset the routing table
route /f

 ::Resets Winsock Catalog to a clean state. Restart computer after this one.
netsh winsock reset all
netsh winsock reset catalog

 ::Restores Windows Firewall with Advanced Security policy to the default policy.
netsh firewall reset

 ::Flushes ARP Cache
netsh int ip delete arpcache

 ::Resets TCP/IP and related components to a clean state. (IPv4 & IPv6)
netsh int ip reset all
netsh int ipv6 reset all

cls
ECHO Starting Services...
Net Start ALG /Y
Net Start BITS /Y
Net Start DHCP /Y
Net Start TrkWks /Y
Net Start Dnscache /Y
Net Start CiSvc /Y
Net Start PolicyAgent /Y
Net Start Nla /Y
Net Start RSVP /Y
Net Start upnphost /Y
Net Start SSDPSRV /Y
Net Start LmHosts /Y
Net Start RasAuto /Y
Net Start RasMan /Y
Net Start TapiSrv /Y
Net Start WebClient /Y
Net Start SharedAccess /Y
Net Start Netman /Y
Net Start Dot3svc /Y
Net Start EapHost /Y
Net Start WZCSVC /Y
Net Start Alerter /Y
Net Start Browser /Y
Net Start LanmanServer /Y
Net Start Messenger /Y
Net Start Netlogon /Y
Net Start RpcLocator /Y
Net Start lanmanworkstation /Y

cls
ECHO Renew IP Settings...
::Release & Renew the IP Configuration & Flush DNS settings.
ipconfig /release
ipconfig /flushdns
netsh interface ip set address "Local Area Connection" dhcp
ipconfig /renew
ipconfig /registerdns

ECHO Operation Completed...
ECHO.
ECHO Reboot computer if network not accessible...
PAUSE

Offline Shane

  • Top Geek, err uh Dog.
  • Administrator
  • Hero Member
  • *****
  • Join Date: Sep 2011
  • Posts: 9279
  • Location: USA
  • Karma: 137
  • "Knowledge should be shared not hidden."
    • View Profile
    • Tweaking.com
Re: Complete Network Reset without needing a Restart
« Reply #1 on: March 11, 2014, 11:42:05 AM »
There are a few commands I dont have in the repair, I will look them over and see if any of them would be good to add to the repair itself :-)

Shane
PLEASE EDIT YOUR TOPIC AND PUT (SOLVED) IF YOU ARE ALL FIXED.

(My weekends belong to my wife and kids, I will try my best to answer all posts daily during the work week)

(About Shane)
Site Owner, Top Admin, Lead Programmer, Wife & 5 kids, Needs a lot more coffee.

When people ask "Why fix what isn't broken?" I reply "To make it better."
"Only a life lived for others is a life worthwhile"
Honor & Respect is all that matters.

Owner & Programmer of: www.pcwintech.com & www.tweaking.com

Offline Rolemodel

  • Newbie
  • *
  • Join Date: Mar 2014
  • Posts: 13
  • Karma: 1
    • View Profile
Re: Complete Network Reset without needing a Restart
« Reply #2 on: March 12, 2014, 10:14:11 AM »
Okay great stuff. Keep up the good work and thanks.