Jump to content
Sign in to follow this  
storme

Setting "Computer name"

Recommended Posts

storme

G'day all

I'm installing a new server (peer-2-peer) network tomorrow. The setup they will have is two servers (server01 & server02) server01 does ALL the work and if it fails they want to rename server02 to server01 do a restore from backup and be up and going.

It's a small concern so no need for hot swap and on-line backups etc.

I foolishly said I'd write a little script (2 buttons) that would

1. Rename the computer (server01/server02)

2. Reboot the server for changes to take effect.

I've found a few examples for doing this by setting the registry but I'd like to know if anyone has tried/succeeded in doing this on a "Windows 7 professional" machine.

This is a piece of code from 2008 by muhmuuh. I haven't tried it yet as I don't want to "mess up" the server. Does anyone know if this will work?

RenameComputerName($userid)

Func _RenameComputerName($sComputerName)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName", "ComputerName","REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $sComputerName) Then Return(1)
    If Not RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $sComputerName) Then Return(1)
    Return(0)
EndFunc

Thanks in advance

John Morrison

aka

Storm-E

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  

×