Jump to content
Sign in to follow this  
tehon3299

Changing Computer Hostname

Recommended Posts

tehon3299

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!

Share this post


Link to post
Share on other sites
emmanuel

it just changes the hostname? so nothing to do with workgroup or domain membership? Can we see the source?


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

Share this post


Link to post
Share on other sites
autoitNOW

Hi, I would like to see the source too.


An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites
emmanuel

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)

Share this post


Link to post
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
Sign in to follow this  

×