General discussion

Locked

Set Computer Name by Mac Address

By kris ·
Hello,

After imaging a suit of computers I currently have to go to each one in turn to set the machines name, as we have several software tools than communicate and log using the machine name as its point of reference.

I believe the best way to achieve my goal is to write a batch file or script that will assign a new machine name by matching the MAC address to a master MAC Address text file.

I can access the MAC address using the command:

getmac /nh /fo table > test.txt


And can interrogate the file with:

findstr.

Can anyone help me fill in the blanks, I am particularly interested in where to change the machine name in the registry so it has a cascade effect upon next reboot. That or a far simpler solution that is probably staring me in the face, and I have overlooked ;-)

Thanks in advance for any help,

Kris Dowse

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by jschein In reply to Set Computer Name by Mac ...

It's great you have learned to image your systems... However, you should have used microsoft's sysprep utility before you made that image. You will now, in addition have to redo the SIDs on every single pc.

Go back to your initial image. Run sysprep on it as your last step. Follow the instructions. Leave one imaged pc on the net at all times. Image your next pc's and power them on. It will automatically create a new SID and when it hits the network will see the name is in use and ask for a new one.

Collapse -

by kris In reply to

Poster rated this answer.

Thanks but I am already Syspreping the images, and have answer file to set up all relivant settings execpt a machine name. We have 30 machines per image roughly and currently the name is randomly generated. By the way your post was not unacceptable - it just didn't help me! Thanks anyway,

Kris

Collapse -

by w2ktechman In reply to Set Computer Name by Mac ...

If you use Sysprep you can setup an image with different SID's. Also, you can create Unattended Installation script. Furthermore, the one that you seem to be interested the most in (assigning computer names) you can create a Uniqueness Database File.
For the systema already setup I have no info for you other than to manually name them.

Collapse -

by kris In reply to

I am more than happy to modify my image, or my sysprep answer file. The idea of creating a database for sysprep to use sounds ideal, but can I specify exactly the machine gets each name. Further help in this area would be greatly received.

Kris

Collapse -

by kris In reply to Set Computer Name by Mac ...

I use Sysprep, and I have created an unattended answer file, the machines set them selves up, modify their own network settings and then reboot. The entire process is automated - I never have to leave my chair - well apart from having to set blessed the machine names, hence the original question!!

I have found the relevant registry entries to change the machine name and cause a cascade effect through the registry since my last post, and can acquire the machines MAC address, I just need to create a batch file that sets the Machine name by MAC address.

Below is a snippet of the way I am working thus far:

GETMAC /NH /FO TABLE > C:\MacAddress.txt

:CHANGENAME
ECHO Windows Registry Editor Version 5.00 >> C:\ComputerName.reg
ECHO. >> C:\ComputerName.reg
ECHO [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName] >> C:\ComputerName.reg
ECHO "ComputerName"="%NewName%" >> C:\ComputerName.reg
ECHO. >> C:\ComputerName.reg
ECHO [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters] >> C:\ComputerName.reg
ECHO "NV Hostname"="%NewName%" >> C:\ComputerName.reg
ECHO. >> C:\ComputerName.reg
ECHO [KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName] >> C:\ComputerName.reg
ECHO "ComputerName"="%NewName%" >> C:\ComputerName.reg
ECHO. >> C:\ComputerName.reg
ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >> C:\ComputerName.reg
ECHO "NV Hostname"="%NewName%" >> C:\ComputerName.reg

REGEDIT.EXE /S C:\ComputerName.reg
DEL C:\ComputerName.reg /q
SHUTDOWN -R

Thanks for the help so far, but still looking to fill in the blanks,

Kris

Collapse -

by kris In reply to

Posted the above in case the chap with the sysprep idea doesn't get back to me, as I had to reject his help in order to reply to him!?! Seems a very odd way of doing things! So please don't be put off y2ktechman, I am happy with all the help thus far, and will be more than happy to allocate some of these points, assuming people actually collect them - do they??

Kris

Collapse -

by w2ktechman In reply to Set Computer Name by Mac ...

When you create a Uniqeness database file you can predetermine names, the only problem is that when you run setup you need to specify the name it should use.
After that, I am unsure, I do not know how to script well right now, and have very little time to try to figure it out. Oh, and no, I wasnt offended by the rejection, but thanks for letting me know.

Collapse -

by kris In reply to

Thanks for the continued input - but I have resolved the problem now. Gave up with scripting and wrote a Java program to interrogate a txt file and do exactly what I needed! I just tell sysprep to run my app after installation and auto login twice - who said three years learning Java on my degree would be useless to me!?!

Collapse -

by kris In reply to Set Computer Name by Mac ...

This question was closed by the author

Back to Windows Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums