Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal enabledelayedexpansion&set args=%*&set v=v3.0&set log=%userprofile%\desktop\netfix.log
- cls & echo.
- echo __ ___
- echo /\ \__ /'___\ __
- echo ___ __\ \ ,_\/\ \__//\_\ __ _
- echo /' _ `\ /'__`\ \ \/\ \ ,__\/\ \ /\ \/'\
- echo /\ \/\ \/\ __/\ \ \_\ \ \_/\ \ \\/^> ^</
- echo \ \_\ \_\ \____\\ \__\\ \_\ \ \_\/\_/\_\
- echo \/_/\/_/\/____/ \/__/ \/_/ \/_/\//\/_/
- echo.
- echo Performs actions similiar to the network repair option and more!
- echo See: http://support.microsoft.com/kb/289256
- echo.
- echo [Optional Switches]
- echo /d - debug mode
- echo /r - detailed reporting
- echo /h - this help screen; no execution.
- echo /w - winsock reset (http://support.microsoft.com/kb/811259) - requires reboot
- echo /t - tcp/ip reset (http://support.microsoft.com/kb/299357) - requires reboot
- echo.
- echo Note: This script requires elevated privileges to operate properly. (Vista/7)
- echo.
- call :getswitch /h
- if [!s!]==[/h] goto :eof
- echo ---[NetFix runtime: %date% %time%]--->!log!
- set p=Releasing IP address
- if exist %windir%\system32\ipconfig.exe
- (
- echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\ipconfig.exe /release 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if [%errorlevel%]==[0] echo Successfully released IP...
- if [%errorlevel%]==[1] echo ERROR: Failed to release IP... check netfix.log
- if [%errorlevel%]==[3] echo NOTE: An IP address has not yet been associated with the network endpoint.
- )
- else
- (
- echo ERROR: failed to release ip address - unable to locate %windir%\system32\ipconfig.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- set p=Flushing ARP cache
- if exist %windir%\system32\netsh.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\netsh.exe interface ip delete arpcache 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if [%errorlevel%]==[0] echo Successfully flushed ARP cache...
- if [%errorlevel%]==[1] echo ERROR: Failed to flush ARP cache... check netfix.log
- )
- else
- (
- if exist %windir%\system32\arp.exe
- (
- %windir%\system32\arp.exe -d * 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if [%errorlevel%]==[0] echo Successfully flushed ARP cache...
- if [%errorlevel%]==[1] (echo ERROR: Failed to flush ARP cache... check netfix.log)
- )
- else
- (
- echo ERROR: failed to flush arp cache - unable to locate %windir%\system32\netsh.exe or %windir%\system32\arp.exe
- )
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- set p=Reloading NetBIOS name cache
- if exist %windir%\system32\nbtstat.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\nbtstat.exe -R 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if [%errorlevel%]==[0] echo Successfully reloaded NetBIOS name cache...
- if [%errorlevel%]==[1] echo ERROR: Failed to reload NetBIOS name cache... check netfix.log
- )
- else
- (
- echo ERROR: Failed to reload netbios name cache - unable to locate %windir%\system32\nbtstat.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- set p=Sending NetBIOS name update
- if exist %windir%\system32\nbtstat.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\nbtstat.exe -RR 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- )
- else
- (
- echo ERROR: Failed to send netbios name update - unable to locate %windir%\system32\nbtstat.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- set p=Flushing DNS cache
- if exist %windir%\system32\ipconfig.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\ipconfig.exe /flushdns >>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- )
- else
- (
- echo ERROR: Failed to flush dns cache - unable to locate %windir%\system32\ipconfig.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- call :getswitch /w
- if [!s!]==[/w] call :winsock
- call :getswitch /t
- if [!s!]==[/t]
- (
- call :tcpip
- )
- else
- (
- set p=Renewing IP address
- if exist %windir%\system32\ipconfig.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\ipconfig.exe /renew >>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- )
- else
- (
- echo ERROR: Failed to renew IP address - unable to locate %windir%\system32\ipconfig.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
- set p=Registering DNS name
- if exist %windir%\system32\ipconfig.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\ipconfig.exe /registerdns >>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- )
- else
- (
- echo ERROR: Failed to register DNS name - unable to locate %windir%\system32\ipconfig.exe)
- )
- call :getswitch /r
- if [!s!]==[/r]
- (
- if exist %windir%\system32\ipconfig.exe
- (
- echo ---[ip configuration]--- >>!log!
- %windir%\system32\ipconfig.exe /all >>!log! 2>>&1
- )
- if exist %windir%\system32\arp.exe
- (
- echo ---[arp table]--- >>!log!
- %windir%\system32\arp.exe -a 1>>!log! 2>>&1
- )
- if exist %windir%\system32\ipconfig.exe
- (
- echo ---[dns resolver cache]--- >>!log!
- %windir%\system32\ipconfig.exe /displaydns >>!log! 2>>&1
- )
- if exist %windir%\system32\nbtstat.exe
- (
- echo ---[netbios name tables]--- >>!log!
- %windir%\system32\nbtstat.exe -c >>!log! 2>>&1
- %windir%\system32\nbtstat.exe -n >>!log! 2>>&1
- %windir%\system32\nbtstat.exe -r >>!log! 2>>&1
- )
- if exist %windir%\system32\netstat.exe
- (
- echo ---[routing table ^& ethernet/protocol stats]--- >>!log!
- %windir%\system32\netstat.exe -r -e -s >>!log! 2>>&1
- )
- if exist %windir%\system32\drivers\etc\hosts
- (
- echo ---[hosts file]--- >>!log!
- type %windir%\system32\drivers\etc\hosts >>!log!
- )
- if exist %windir%\system32\netstat.exe
- (
- echo. & echo Please wait while I generate a detailed network report...
- echo ---[all network connections ^& processes]--- >>!log!
- %windir%\system32\netstat.exe -a -b -o -f >>!log! 2>>&1
- )
- )
- )
- echo. & echo Network Repair Complete! & echo ---[Finished: %date% %time%]--->>!log!
- title NetFix %v% by Giovanni Heward (giovanni@hewardassociates.com) complete
- goto :eof
- :getswitch
- echo !args!|find.exe /i "%1" >nul 2>&1
- if %errorlevel%==0 set s=%1
- goto :eof
- :tcpip
- set p=Resetting TCP/IP
- if exist %windir%\system32\netsh.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\netsh.exe int ip reset %userprofile%\desktop\netreset.log 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if %errorlevel%==0
- (
- echo Successfully reset TCP/IP
- echo Note: This fix requires a system restart... run "shutdown /a" to abort.
- if exist %windir%\system32\shutdown.exe %windir%\system32\shutdown.exe /r
- )
- else
- (
- echo ERROR: Failed to reset tcp/ip... check netfix.log
- )
- )
- else
- (
- echo ERROR: Failed to reset tcp/ip - unable to locate %windir%\system32\netsh.exe
- )
- goto :eof
- :winsock
- set p=Resetting Winsock
- if exist %windir%\system32\netsh.exe
- (
- echo. & echo !p! & title !p! & echo ---[!p!]--- >>!log!
- %windir%\system32\netsh.exe winsock reset 1>>!log! 2>>&1
- call :getswitch /d
- if [!s!]==[/d] echo errorlevel: %errorlevel%
- if %errorlevel%==0
- (
- echo Successfully reset winsock
- echo Note: This fix requires a system restart... run "shutdown /a" to abort.
- if exist %windir%\system32\shutdown.exe %windir%\system32\shutdown.exe /r
- )
- else
- (
- echo Failed to reset winsock... check netfix.log
- )
- )
- else
- (
- echo ERROR: Failed to reset winsock - unable to locate %windir%\system32\netsh.exe
- )
- call :getswitch /d
- if [!s!]==[/d] pause
Advertisement
Add Comment
Please, Sign In to add comment