Solved

Script to assign computer names based on MAC address

Posted on 2006-07-02
7
1,217 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:logic0004
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:yotamsher
ID: 17027851
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
next

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 _
    objWMIService.InstancesOf("Win32_ComputerSystem")

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

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

good luck

Yotam
0
 
LVL 2

Author Comment

by:logic0004
ID: 17028840
Commercial products like what ??
 
can u post some links for those kind of products ?
0
 
LVL 7

Expert Comment

by:yotamsher
ID: 17029691
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
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 10

Accepted Solution

by:
fostejo earned 500 total points
ID: 17038450
logic0004,

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..
0
 
LVL 2

Author Comment

by:logic0004
ID: 17078610
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....
0
 
LVL 10

Expert Comment

by:fostejo
ID: 17103026
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..

cheers,
0
 
LVL 2

Author Comment

by:logic0004
ID: 17107579
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.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 90
Tembedded WB animatid gifs not animated on some pcs 2 84
Bot application - advice 3 38
Programming Codes 2 21
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question