Guest User

Untitled

a guest
Sep 11th, 2013
1,189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.43 KB | None | 0 0
  1. ::::::::::::::::::::::::::::::::::::::::::::
  2. :: Author: The_one_the_only_God           ::
  3. :: Purpose: Diagnostic and repair utility ::
  4. :: Date: 11/09/2013                       ::
  5. :: Version: 2.0                           ::
  6. ::::::::::::::::::::::::::::::::::::::::::::
  7.  
  8. @echo off
  9. TITLE %~nx0
  10. mode con:cols=90 lines=20
  11.  
  12. REM Let's set some variables first. Choose a domain IP to ping from the broken computer. Not much point changing the WANIP.
  13. SET DOMAINIP=10.10.10.20
  14. SET WANIP=8.8.8.8
  15. SET LOGFILE=%temp%\DIAGRESULTS.log
  16.  
  17. echo(
  18. echo This is a keyboard-driven utility for basic diagnostic and repair.
  19. echo Please read all instructions carefully and close ALL running programs.
  20. echo Your computer may automatically log off.
  21. echo Your computer may automatically restart.
  22. echo(
  23. pause
  24. cls
  25.  
  26. echo(
  27. echo Beginning diagnostics and repair in 10 seconds. Press CTRL+C to quit.
  28. echo Please do not press CTRL+C beyond this point.
  29. choice /C X /T 10 /D X > nul
  30. cls
  31.  
  32. REM Add computer name, date and time to the beginning of the log file.
  33. echo( >> %LOGFILE%
  34. echo %COMPUTERNAME% %DATE% %TIME% >> %LOGFILE%
  35.  
  36. REM Asks if the issue is network related or not, then proceeds accordingly.
  37. 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."
  38. IF ERRORLEVEL 2 GOTO NOTNET
  39. IF ERRORLEVEL 1 GOTO NET
  40.  
  41. :NET
  42. cls
  43. REM Test connection to the domain via ping. (Domain controller.)
  44. :DOMAIN
  45. echo(
  46. echo Testing connection to the domain.
  47. ping %DOMAINIP% >> %LOGFILE%
  48. if %ERRORLEVEL% GTR 0 echo Connection to the domain has failed. & goto RENEW
  49. if %ERRORLEVEL% EQU 0 echo Connection to the domain succeeded. & goto WORLD
  50.  
  51. REM Test connection to the internet via ping. (Google's DNS server.)
  52. :WORLD
  53. echo(
  54. echo Testing connection to the internet.
  55. ping %WANIP% >> %LOGFILE%
  56. if %ERRORLEVEL% GTR 0 echo Connection to the internet has failed. & goto RENEW
  57. if %ERRORLEVEL% EQU 0 echo Connection to the internet succeeded. & goto FLUSHDNS
  58.  
  59. REM Flush DNS cache to remove any incorrect records.
  60. :FLUSHDNS
  61. echo(
  62. echo Flushing DNS records.
  63. ipconfig /flushdns >> %LOGFILE%
  64. if %ERRORLEVEL% GTR 0 echo Unable to flush records. & goto ERROR1
  65. if %ERRORLEVEL% EQU 0 echo Successfully flushed records. & goto FIXED
  66.  
  67. REM This will release the current I.P address and ask for a new one.
  68. REM I'm not sure if the pause is necessary, whatever. No harm done.
  69. :RENEW
  70. cls
  71. echo Releasing I.P addresses.
  72. ipconfig /release
  73. echo Waiting for stuff to happen...
  74. choice /C X /T 15 /D X > nul
  75. echo Renewing I.P addresses.
  76. ipconfig /renew
  77. echo Waiting for more stuff to happen...
  78. choice /C X /T 15 /D X > nul
  79. goto FIXED
  80.  
  81. REM Starts here if it's not network related.
  82. REM This quite often fixes missing printers deployed through GPP.
  83. :NOTNET
  84. cls
  85. :GPUPDATE
  86. echo Refreshing group policies.
  87. gpupdate >> %LOGFILE%
  88. if %ERRORLEVEL% GTR 0 echo Unable to refresh policies. & goto ERROR1
  89. if %ERRORLEVEL% EQU 0 echo Successfully refreshed policies. & goto FIXED
  90.  
  91. REM Error messages
  92. :ERROR1
  93. echo General failure.
  94. pause
  95. end
  96.  
  97. REM End of script messages
  98. :FIXED
  99. echo(
  100. choice /C YN /T 400 /D Y /M "Is your problem resolved?"
  101. IF ERRORLEVEL 2 GOTO REBOOT
  102. IF ERRORLEVEL 1 GOTO FINISH
  103.  
  104. :FINISH
  105. cls
  106. echo Huzzah! You can quit now.
  107. pause
  108. exit
  109.  
  110. :REBOOT
  111. cls
  112. echo Can't find the issue. Manual intervention may be required.
  113. echo Rebooting PC as a last resort.
  114. shutdown /r /t 10 /c "Rebooting system in 10 seconds."
  115. pause
  116. exit
Advertisement
Add Comment
Please, Sign In to add comment