Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::::::::::::::::::::::::::::::::::::::::::::
- :: Author: The_one_the_only_God ::
- :: Purpose: Diagnostic and repair utility ::
- :: Date: 11/09/2013 ::
- :: Version: 2.0 ::
- ::::::::::::::::::::::::::::::::::::::::::::
- @echo off
- TITLE %~nx0
- mode con:cols=90 lines=20
- REM Let's set some variables first. Choose a domain IP to ping from the broken computer. Not much point changing the WANIP.
- SET DOMAINIP=10.10.10.20
- SET WANIP=8.8.8.8
- SET LOGFILE=%temp%\DIAGRESULTS.log
- echo(
- echo This is a keyboard-driven utility for basic diagnostic and repair.
- echo Please read all instructions carefully and close ALL running programs.
- echo Your computer may automatically log off.
- echo Your computer may automatically restart.
- echo(
- pause
- cls
- echo(
- echo Beginning diagnostics and repair in 10 seconds. Press CTRL+C to quit.
- echo Please do not press CTRL+C beyond this point.
- choice /C X /T 10 /D X > nul
- cls
- REM Add computer name, date and time to the beginning of the log file.
- echo( >> %LOGFILE%
- echo %COMPUTERNAME% %DATE% %TIME% >> %LOGFILE%
- REM Asks if the issue is network related or not, then proceeds accordingly.
- choice /C YN /T 15 /D Y /M "Is your problem network related? (No internet/server access etc.) If you're not sure just wait."
- IF ERRORLEVEL 2 GOTO NOTNET
- IF ERRORLEVEL 1 GOTO NET
- :NET
- cls
- REM Test connection to the domain via ping. (Domain controller.)
- :DOMAIN
- echo(
- echo Testing connection to the domain.
- ping %DOMAINIP% >> %LOGFILE%
- if %ERRORLEVEL% GTR 0 echo Connection to the domain has failed. & goto RENEW
- if %ERRORLEVEL% EQU 0 echo Connection to the domain succeeded. & goto WORLD
- REM Test connection to the internet via ping. (Google's DNS server.)
- :WORLD
- echo(
- echo Testing connection to the internet.
- ping %WANIP% >> %LOGFILE%
- if %ERRORLEVEL% GTR 0 echo Connection to the internet has failed. & goto RENEW
- if %ERRORLEVEL% EQU 0 echo Connection to the internet succeeded. & goto FLUSHDNS
- REM Flush DNS cache to remove any incorrect records.
- :FLUSHDNS
- echo(
- echo Flushing DNS records.
- ipconfig /flushdns >> %LOGFILE%
- if %ERRORLEVEL% GTR 0 echo Unable to flush records. & goto ERROR1
- if %ERRORLEVEL% EQU 0 echo Successfully flushed records. & goto FIXED
- REM This will release the current I.P address and ask for a new one.
- REM I'm not sure if the pause is necessary, whatever. No harm done.
- :RENEW
- cls
- echo Releasing I.P addresses.
- ipconfig /release
- echo Waiting for stuff to happen...
- choice /C X /T 15 /D X > nul
- echo Renewing I.P addresses.
- ipconfig /renew
- echo Waiting for more stuff to happen...
- choice /C X /T 15 /D X > nul
- goto FIXED
- REM Starts here if it's not network related.
- REM This quite often fixes missing printers deployed through GPP.
- :NOTNET
- cls
- :GPUPDATE
- echo Refreshing group policies.
- gpupdate >> %LOGFILE%
- if %ERRORLEVEL% GTR 0 echo Unable to refresh policies. & goto ERROR1
- if %ERRORLEVEL% EQU 0 echo Successfully refreshed policies. & goto FIXED
- REM Error messages
- :ERROR1
- echo General failure.
- pause
- end
- REM End of script messages
- :FIXED
- echo(
- choice /C YN /T 400 /D Y /M "Is your problem resolved?"
- IF ERRORLEVEL 2 GOTO REBOOT
- IF ERRORLEVEL 1 GOTO FINISH
- :FINISH
- cls
- echo Huzzah! You can quit now.
- pause
- exit
- :REBOOT
- cls
- echo Can't find the issue. Manual intervention may be required.
- echo Rebooting PC as a last resort.
- shutdown /r /t 10 /c "Rebooting system in 10 seconds."
- pause
- exit
Advertisement
Add Comment
Please, Sign In to add comment