storme Posted July 11, 2010 Share Posted July 11, 2010 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 Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now