Skip to content

Change Computer Name

Featured Replies

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!

  • Author

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

  • 4 months later...

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 ;)

Forgot to write that you should save the above code as a .vbs script.

 

Cheers! ^_^

  • 3 months later...

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.