Jump to content

Changing Computer Hostname


tehon3299
 Share

Recommended Posts

I just finished writing my BETA script to change a computers hostname. This script will do an nslookup on the ip address of your computer and parse out the hostname it returns. Then it changes 4 registry settings that affect the hostname. Once that is done, you need to reboot and your hostname will now be changed. You can open a command prompt and type 'hostname' to see your hostname. You can download this script from http://www.oswego.edu/~tehonica/hostname_changer.exe

Remember, this is a beta script. Please post all feedback you have!

Thanks!

Link to comment
Share on other sites

just decompiled the exe...

; <COMPILER: v3.0.101.0>
$IP = @IPAddress1
RunWait(@Comspec & " /c """ & "nslookup "" " & $IP & " > hostname.txt")
$file = FileOpen("hostname.txt", 0)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
$line = FileReadLine($file, 4)
FileClose($file)
$array = StringSplit($line, ":.")
$hostname = $array[2]
$hostname = StringReplace($hostname, " ", "")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $hostname)
MsgBox(0, "Done", "Done")

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...