Advertisement
Guest User

AddHost - DontMakeMeDoIT

a guest
Dec 16th, 2011
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; Language:       English
  3. ; Platform:       Win9x/NT
  4. ; Author:         JRWR/DontMakeMeDoIT <http://forrest.fuqua.networklabs.org>
  5. ;
  6.  
  7.  
  8. #NoEnv
  9. #SingleInstance
  10. #NoTrayIcon
  11. #UseHook Off
  12.  
  13. If not A_IsAdmin { ; Runs script as Administrator for UAC in Windows Vista and 7+
  14.     Run *RunAs "%A_ScriptFullPath%"
  15.     ExitApp
  16.   }
  17.  
  18. SetWorkingDir %A_ScriptDir%
  19. ;%A_WinDir%\System32\drivers\etc\hosts
  20. InputBox, hostname, DNS Lookup, Do NOT enter the WWW. prefix`, just the domain name:
  21.  
  22. AutoTrim, On
  23.  
  24. hostname := RegExMatch(hostname, ".*(\b\w+\.\w+)", hostname)
  25. hostname = %hostname1%
  26.  
  27. tf = %A_Temp%\%A_Now%
  28. RunWait, %ComSpec% /c "nslookup %hostname% 8.8.8.8" > %tf%, , Hide
  29.  
  30. FileRead, ip, %tf%
  31. FileDelete, %tf%
  32.  
  33. StringSplit, DNSArray, ip,%A_Space%,
  34. ipaddress = %DNSArray11%
  35. IfNotInString, ipaddress,.
  36. {
  37. Msgbox, ERROR: IP Lookup FAILED`nDebug: Returned IP String:`n%ip%
  38. ExitApp,
  39. }
  40.  
  41. IfInString, ipaddress,8.8.8.8
  42. {
  43. Msgbox, ERROR: IP Lookup FAILED`nDebug: Returned IP String:`n%ip%
  44. ExitApp,
  45. }
  46.  
  47. MsgBox,4, ,Does This look correct?`nShould look like:`ngoogle.com 74.125.65.147`n-----------------------`n`n%hostname% %ipaddress%
  48. IfMsgBox No
  49. {
  50.     Msgbox, Aborted!
  51.     ExitApp,
  52.  
  53. }
  54. FileAppend,
  55. (
  56.  
  57. #Added %A_MMMM% %A_DD% %A_YYYY%
  58.  
  59. ), %A_WinDir%\System32\drivers\etc\hosts
  60. FileAppend,
  61. (
  62. %hostname% %ipaddress%
  63. ), %A_WinDir%\System32\drivers\etc\hosts
  64. MsgBox, 4, , Do you want to open your HOSTS file in notepad? (Press YES or NO)
  65. IfMsgBox No
  66.     return
  67. RunWait, %A_WinDir%\Notepad.exe %A_WinDir%\System32\drivers\etc\hosts
  68. ExitApp,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement