list computer hosts file bindings


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. resultPath ="c:\Scripts\Resultados\hosts.txt"
  2.  
  3. set shell = WScript.CreateObject("WScript.Shell")
  4.  
  5. Set objFSO = CreateObject("Scripting.FileSystemObject")
  6. Set srcFile = objFSO.OpenTextFile(shell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\drivers\etc\hosts", 1)
  7.  
  8. Set objFSOW = CreateObject("Scripting.FileSystemObject")
  9. Set destFile = objFSOW.CreateTextFile(resultPath)
  10.  
  11.  
  12. Do Until srcFile.AtEndOfStream
  13.  
  14.  
  15. line = srcFile.ReadLine
  16. if Left(line,1) <> "#" AND Trim(Trim(line)) <> "" AND LEN(Replace(line,VBTab,"")) > 0 then
  17. ' Wscript.Echo line
  18. destFile.WriteLine line
  19. end if
  20.  
  21. Loop
  22. srcFile.Close
  23.  
  24.  
  25. destFile.close
  26.  
  27.  
  28. shell.Run "notepad " & resultPath

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.