Jump to content


  • 0
jace5869

Change Computer Name

Question

Basically what I need is a script that will somehow look at the MAC address (possible through ipconfig /all or sysinfo or something) of the Local Area Network connection (on-board NIC) and change the computer to something like:

 

C:> ipconfig /all

 

IP ........................... 192.168.0.2

Subnet mask............ 255.255.255.0

Default Gateway....... 192.168.0.1

MAC........................ 00-1E-4F-F5-89-66

 

 

Add 'US' to the MAC -> US00-1E-4F-F5-89-66 -> Remove the dashes -> US001E4FF58966

 

Sorry, for dragging out all of that, I just didn't want any misunderstandings about what I was trying to achieve, I'm not great at scripting at all -- I'm trying to learn (I'm just an intermediate Batch file scripter).

I don't mind if the script is in BATCH, VBScript, PERL, Python ... but I think it would probably be something easily done through VBScript. Like I said, I'm willing to learn as much as possible so if you could run me through what ever you have I would appreciate it.

 

I'm looking at making either a Automated Windows Deployment and need a way of running a script to change the name -- and then add the computer to the domain. since all of this economy crisis it would be hard to get my work to purchase hundreds of licenses of a Ghost/Symantec product to manage this.

 

Thanks!

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Looking through the Server 2003 Resource Kit I have this VBScript??

 

ErrResults = oComputer.Rename(WScript.Arguments.Named("name"),Null,Null)
If ErrResults <> 0 Then
 WScript.Echo " ***Error Renaming: " & ErrResults
Else
 Verbose "Rename successful. Restart of remote computer is necessary. "
End If

 

Do you think this will be sufficient enough? I'm still at a loss as to how to make this change the name based on MAC Address

Share this post


Link to post
Share on other sites

  • 0

Try this script:

 

It will change your computername to US+MACADDR (without any ":")

Example (XP in swedish but i think you understand how it works):

post-2500-1234619685_thumb.png

 

After this script has run you need to restart your computer and if your computer was in a domain you need to readd the computer to the domain.

If you need more help with this give me a ping and ill show you how to do a script that will allso rejoin the computer to a domain.

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMACADDR = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objMACADDR in colMACADDR
 strMAC = objMACADDR.MACAddress
 If strMAC <> "" Then exit For
Next 

strMAC=replace(strMAC,":","")

Set ws = WScript.CreateObject("WScript.Shell")
value1 = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"
value2 = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\ParameterS\"
ws.RegWrite value1 & "ComputerName", "US" & strMAC
ws.RegWrite value2 & "NV Hostname", "US" & strMAC

 

This is only tested on winXP, will get back to you guys once tested on Vista. Will allso upload an english picture once i get the chance ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.