• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1351
  • Last Modified:

Script to assign computer names based on MAC address

Hi all,

I want to assign computer names using the MAC addresses. The company has around 500 computers and after ghosting, its a big time consuming task to assign computer name manually to each system. So, is there a way that we have list of MAC address -- computer names and the script runs and finds the local MAC address and then assigns the related computer name to the system.

I need to whole code if its possible. The computers are running WinXP SP2. May be it can be done using VB.net but i m not an expert programmer...

Any help would be appreciated.
  • 3
  • 2
  • 2
1 Solution
Hey logic0004

from Your question it seems to me that your company need something like Microsoft System Management Server.

but being specific about programming, here is my answer split into two parts:

1) the following script aquires the MAC address(s)
just put it in a .vbs file and run it

Set NetAdapterSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select *

from Win32_NetworkAdapter")
for each NetAdapter in NetAdapterSet
   wscript.echo NetAdapter.MACAddress

2) The following script from Microsoft site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_start_page.asp)
is supposed to rename the computer ( I did not try it)

Name = "name"
Password = "password"
Username = "username"

Set objWMIService = GetObject("Winmgmts:root\cimv2")

' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _

        Return = objComputer.rename(Name,Password,User)
        If Return <> 0 Then
           WScript.Echo "Rename failed. Error = " & Err.Number
           WScript.Echo "Rename succeeded." & _
               " Reboot for new name to go into effect"
        End If

again, In the scale you are talking about I would consider a comercial product

good luck

logic0004Author Commented:
Commercial products like what ??
can u post some links for those kind of products ?
I think "Microsoft SMS" http://www.microsoft.com/smserver/default.mspx
can do what you need.
but hey, I'm a programmer not a real IT expert
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Something like WSName.exe available at http://mystuff.clarke.co.nz/wsname.asp may do the trick - it seems pretty comprehensive and is well documented, allowing you to change the computer name via one command line (fired from a VBScript, batch file etc.) by taking into account a wide variety of different attributes including the MAC address.  It can also assign names randomly, and takes into account Domain membership etc.

hope that helps..
logic0004Author Commented:
Thanks , fostejo for the link.

The stuff up there is very useful and I would appreciate if u can post few more links have cool stuff like that....
Hi logic0004,

The program mentioned in my previous response is just about the best I've seen for doing the specific task as per your question.

There are probably too many potential links with 'cool stuff' to list (!) - is there anything specific related to your question you're looking for? - I (and others) will then be better placed to direct you accordingly..

logic0004Author Commented:
Actually we are working on another project which includes CISCO routers and switches, and we want to build an interface like a webpage where u enter the MAC address, IP address, port number etc. (depending upon the requirement) for opening that specific port for the specified MAC address.

The basic idea is to connect the webpage to issue commands at the backend to the router. Like the information will go to the database and there must be some form of script or program running which pulls the required information from the database and telnet to the router/switch to the exexute the command on them.

I couldn't find much information yet, any help or link u can provide to do the job would be appreciated.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now