Saturday 6 June 2009

'"Hosts" File Edit'er

Ok. I am making words up. But I am too drunk to think straight. I am sick of Windows' administrator rights and stuff. Everytime it asks me that permission thingie to edit that file, I get iritated, so I wrote this tiny little script. And sharing it with you, it's pretty simple write an IP address and then write the name for it. It will add it to hosts file. So you won't need editing it or any free dns or something like it. Just give your user `the right` from security tab to access to that stoopeed file and use my script. That's it. If you don't already know what I am talking about, you should ignore this post. Here's the tiny .VBS script.

Dim Stuff, FileSys, WriteStuff
ip=inputbox("IP?")
domain=inputbox("Domain?")
Stuff = ip & " " & domain
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = FileSys.OpenTextFile("c:\windows\system32\drivers\etc\hosts", 8, True)
WriteStuff.WriteLine(Stuff)
WriteStuff.Close
SET WriteStuff = NOTHING
SET FileSys = NOTHING

Notice that there is no exception handling or something, I assumed you are smart enough to execute this properly. Thanks for watching.

Scripting is even funnier, when you are drunk. I should try Sed&Awk...

No comments:

Post a Comment