Jump to content

How to rename large numbers of XP systems


Recommended Posts

Guest Sandy Wood
Posted

Our network has over 900 XP systems that we need to rename. We're looking for

a way to script or otherwise automate the process. We need to change a single

character in the computer name to remove an underscore and replace it with a

dash. We believe we can vbscript a search and replace script but beyond that

have only begun to look into the process. Has anyone done anything like this

before without physically visiting each system?

--

Sandy Wood

Orange County District Attorney

  • Replies 6
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: How to rename large numbers of XP systems

 

 

"Sandy Wood" <sandy.wood@nospam.com> wrote in message

news:8608DFD6-6757-4F42-BE68-3302C5A1B029@microsoft.com...

> Our network has over 900 XP systems that we need to rename. We're looking

> for

> a way to script or otherwise automate the process. We need to change a

> single

> character in the computer name to remove an underscore and replace it with

> a

> dash. We believe we can vbscript a search and replace script but beyond

> that

> have only begun to look into the process. Has anyone done anything like

> this

> before without physically visiting each system?

> --

> Sandy Wood

> Orange County District Attorney

 

Below is an untested script I found in this newsgroup some

time ago. With a bit of tweaking it could do the job for you -

if it works! Alternatively you could try netdom.exe. Remember

that renaming each PC is only half the job - you also have to

rejoin it to your domain.

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colComputers = objWMIService.ExecQuery _

("Select * from Win32_ComputerSystem")

 

strcomputer = InputBox("Enter New Computer Name")

 

If strComputer = "" then

Wscript.quit

End If

 

For Each objComputer in colComputers

err = objComputer.Rename(strComputer)

Next

 

'Joining a computer to a domain

'=========================

Const JOIN_DOMAIN = 1

Const ACCT_CREATE = 2

Const ACCT_DELETE = 4

Const WIN9X_UPGRADE = 16

Const DOMAIN_JOIN_IF_JOINED = 32

Const JOIN_UNSECURE = 64

Const MACHINE_PASSWORD_PASSED = 128

Const DEFERRED_SPN_SET = 256

Const INSTALL_INVOCATION = 262144

 

strDomain = InputBox("Enter Domain name to Join")

strUser = InputBox("Enter Domain User to join domain")

strPassword = Inputbox("Enter password")

 

Set objNetwork = CreateObject("WScript.Network")

strComputer = objNetwork.ComputerName

 

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" _

& strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _

& strComputer & "'")

 

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _

strPassword, _

strDomain & "\" & strUser, _

"cn=Computers,DC=mydomain,dc=com", JOIN_DOMAIN + ACCT_CREATE)

 

If ReturnValue = 0 Then

MsgBox "Computer added to domain under old name without error.

Proceeding to change computer name. "

Else

MsgBox "Computer not added to domain successfully. Return value: " &

ReturnValue

End If

Posted

Re: How to rename large numbers of XP systems

 

=?Utf-8?B?U2FuZHkgV29vZA==?= wrote:

>

> Our network has over 900 XP systems that we need to rename. We're looking for

> a way to script or otherwise automate the process. We need to change a single

> character in the computer name to remove an underscore and replace it with a

> dash. We believe we can vbscript a search and replace script but beyond that

> have only begun to look into the process. Has anyone done anything like this

> before without physically visiting each system?

 

Very dangerous to use an automated process for that. You're lible to

toast the entire network.

 

--

http://www.bootdisk.com/

Guest Monitor
Posted

Re: How to rename large numbers of XP systems

 

 

"Plato" <|@|.|> wrote in message

news:48acb2c0$0$30937$bb4e3ad8@newscene.com...

> =?Utf-8?B?U2FuZHkgV29vZA==?= wrote:

> >

> > Our network has over 900 XP systems that we need to rename. We're

looking for

> > a way to script or otherwise automate the process. We need to change a

single

> > character in the computer name to remove an underscore and replace it

with a

> > dash. We believe we can vbscript a search and replace script but beyond

that

> > have only begun to look into the process. Has anyone done anything like

this

> > before without physically visiting each system?

>

> Very dangerous to use an automated process for that. You're lible to

> toast the entire network.

>

 

"lible"? Did you perhaps mean "liable"?

 

Anyway, there are three conceivable outcomes if the OP goes ahead

with her automated process:

a) It works.

b) It does not work and she has to do it manually.

c) The renaming works but she has to join the the machines

manually to the domain.

 

If you can think of a further scenario then please supply details.

Posted

Re: How to rename large numbers of XP systems

 

Peruse this and you should find something you like.

 

 

Website:

 

Change computer name and add to the domain (VB Script)

http://en.allexperts.com/q/VB-Script-2351/Change-computer-name-add.htm

 

 

Batch file:

 

reg update "hkcr\clsid\{20d04fe0-3aea-1069-a2d8-08002b30309d}\localizedstring=My

Computer %%computername%%" reg_expand_sz

 

 

A full VBS file:

 

; Renaming of Computer's Name using VBScript

 

Option Explicit

 

Dim Text, Title

Dim WshNetwork ' Object variable

Text = "Networking information" & vbCrLf & vbCrLf

Title = "Rename Hostname?"

 

' Create a new WshNetwork object to access network properties.

Set WshNetwork = WScript.CreateObject("WScript.Network")

 

Text = Text & "Computer name : " & WshNetwork.ComputerName & vbCrLf

Text = Text & "Domain : " & WshNetwork.UserDomain & vbCrLf

Text = Text & "User name : " & WshNetwork.UserName & vbCrLf & vbCrLf

Text = Text & "Do you want to rename this computer?"

 

If MsgBox(Text, vbYesNo + vbQuestion, Title) = vbyes Then

Dim strComputerName, objWMIService, objComputer, returnCode

 

strComputerName = InputBox("Enter a new machine name for this computer:",

"Rename Computer")

 

If strComputerName <> "" Then

 

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

 

' Call always gets only one Win32_ComputerSystem object.

For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem")

ReturnCode = objComputer.Rename(strComputerName)

Next

If ReturnCode <> 0 Then

MsgBox "There was a problem changing the computer name. System error code :

" & ReturnCode

Else

If MsgBox("Changes made. Do you wish to restart the computer?", vbYesNo +

vbQuestion, Title) = vbyes Then

objShell.Run "rundll32 shell32.dll,SHExitWindowsEx 2", 1, False

Else

MsgBox "You must restart computer for changes to take effect"

End If

End If

End If

End If

 

 

ju.c

 

 

"Monitor" <nospam@spam.com> wrote in message

news:#LsuFe1AJHA.3400@TK2MSFTNGP05.phx.gbl...

>

> "Plato" <|@|.|> wrote in message

> news:48acb2c0$0$30937$bb4e3ad8@newscene.com...

>> =?Utf-8?B?U2FuZHkgV29vZA==?= wrote:

>> >

>> > Our network has over 900 XP systems that we need to rename. We're

> looking for

>> > a way to script or otherwise automate the process. We need to change a

> single

>> > character in the computer name to remove an underscore and replace it

> with a

>> > dash. We believe we can vbscript a search and replace script but beyond

> that

>> > have only begun to look into the process. Has anyone done anything like

> this

>> > before without physically visiting each system?

>>

>> Very dangerous to use an automated process for that. You're lible to

>> toast the entire network.

>>

>

> "lible"? Did you perhaps mean "liable"?

>

> Anyway, there are three conceivable outcomes if the OP goes ahead

> with her automated process:

> a) It works.

> b) It does not work and she has to do it manually.

> c) The renaming works but she has to join the the machines

> manually to the domain.

>

> If you can think of a further scenario then please supply details.

>

>

Posted

VBScript - no word-wrap

 

VBScript - no word-wrap

 

; Renaming of Computer's Name using VBScript

 

Option Explicit

 

Dim Text, Title

Dim WshNetwork ' Object variable

Text = "Networking information" & vbCrLf & vbCrLf

Title = "Rename Hostname?"

 

' Create a new WshNetwork object to access network properties.

Set WshNetwork = WScript.CreateObject("WScript.Network")

 

Text = Text & "Computer name : " & WshNetwork.ComputerName & vbCrLf

Text = Text & "Domain : " & WshNetwork.UserDomain & vbCrLf

Text = Text & "User name : " & WshNetwork.UserName & vbCrLf & vbCrLf

Text = Text & "Do you want to rename this computer?"

 

If MsgBox(Text, vbYesNo + vbQuestion, Title) = vbyes Then

Dim strComputerName, objWMIService, objComputer, returnCode

 

strComputerName = InputBox("Enter a new machine name for this computer:", "Rename Computer")

 

If strComputerName <> "" Then

 

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

 

' Call always gets only one Win32_ComputerSystem object.

For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem")

ReturnCode = objComputer.Rename(strComputerName)

Next

If ReturnCode <> 0 Then

MsgBox "There was a problem changing the computer name. System error code : " & ReturnCode

Else

If MsgBox("Changes made. Do you wish to restart the computer?", vbYesNo + vbQuestion, Title) = vbyes Then

objShell.Run "rundll32 shell32.dll,SHExitWindowsEx 2", 1, False

Else

MsgBox "You must restart computer for changes to take effect"

End If

End If

End If

End If

Posted

Re: How to rename large numbers of XP systems

 

More!

 

 

Windows 2000 Unattended Installations and related utilities

http://www.willowhayes.co.uk/

http://www.willowhayes.co.uk/download/compname.exe

 

Compname.exe is a utility to dynamically generate and set the computer name at the command line.

 

 

How to change computername

http://groups.google.co.uk/group/microsoft.public.win2000.cmdprompt.admin/msg/c2523370d044e7b3?dmode=source&hl=en

 

quote/

Compname.exe is a utility to generate a computer name to your

specifications, optionally pulling in data including asset tag/serial

number from the chassis, motherboard and system, System UUID/GUID, mac

address, IP address octets, date, and a random element.

 

The program should run fine on all Windows platforms since Windows 95,

including Windows NT. If available (i.e 2000, XP, .net) the program

will call SetComputerNameExA from kernel32.dll. If this function is

not available, it calls SetComputerNameA from the same DLL. This

ensures that, for 2000 and above, the DNS host name and the NetBIOS

name both get set properly.

 

Download the utility and type "compname.exe /?" to get the syntax.

It's pretty easy.

 

For example,

 

"compname.exe /c jupiter" sets the computer name to jupiter

"compname.exe /c PC-?k-?l" will use the IP address. If the IP address

is 192.168.1.100, the name will be "PC-1-100"

"compname.exe /c pc-?s" sets the machine to "pc-abcdef" where abcdef

is the SMBIOS asset tag/serial number.

"compname.exe /c pc-?9" generates a name including nine random

characters.

 

The program can also be used for reading any of these fields (by using

the /d[isplay] option), or for piping these numbers into other

applications.

 

"compname.exe /s" will give you a summary of the SMBIOS, IP and MAC

information.

 

Any comments, bug reports or suggestions for improvements are very

welcome.

/quote

 

ju.c

 

 

"ju.c" <bibidybubidyboop@mailnator.com> wrote in message

news:esiQ7p3AJHA.4172@TK2MSFTNGP03.phx.gbl...

> Peruse this and you should find something you like.

>

>

> Website:

>

> Change computer name and add to the domain (VB Script)

> http://en.allexperts.com/q/VB-Script-2351/Change-computer-name-add.htm

>

>

> Batch file:

>

> reg update "hkcr\clsid\{20d04fe0-3aea-1069-a2d8-08002b30309d}\localizedstring=My Computer

> %%computername%%" reg_expand_sz

>

>

> A full VBS file:

>

> ; Renaming of Computer's Name using VBScript

>

> Option Explicit

>

> Dim Text, Title

> Dim WshNetwork ' Object variable

> Text = "Networking information" & vbCrLf & vbCrLf

> Title = "Rename Hostname?"

>

> ' Create a new WshNetwork object to access network properties.

> Set WshNetwork = WScript.CreateObject("WScript.Network")

>

> Text = Text & "Computer name : " & WshNetwork.ComputerName & vbCrLf

> Text = Text & "Domain : " & WshNetwork.UserDomain & vbCrLf

> Text = Text & "User name : " & WshNetwork.UserName & vbCrLf & vbCrLf

> Text = Text & "Do you want to rename this computer?"

>

> If MsgBox(Text, vbYesNo + vbQuestion, Title) = vbyes Then

> Dim strComputerName, objWMIService, objComputer, returnCode

>

> strComputerName = InputBox("Enter a new machine name for this computer:", "Rename Computer")

>

> If strComputerName <> "" Then

>

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

>

> ' Call always gets only one Win32_ComputerSystem object.

> For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem")

> ReturnCode = objComputer.Rename(strComputerName)

> Next

> If ReturnCode <> 0 Then

> MsgBox "There was a problem changing the computer name. System error code : " & ReturnCode

> Else

> If MsgBox("Changes made. Do you wish to restart the computer?", vbYesNo + vbQuestion, Title) =

> vbyes Then

> objShell.Run "rundll32 shell32.dll,SHExitWindowsEx 2", 1, False

> Else

> MsgBox "You must restart computer for changes to take effect"

> End If

> End If

> End If

> End If

>

>

> ju.c

>

>

> "Monitor" <nospam@spam.com> wrote in message news:#LsuFe1AJHA.3400@TK2MSFTNGP05.phx.gbl...

>>

>> "Plato" <|@|.|> wrote in message

>> news:48acb2c0$0$30937$bb4e3ad8@newscene.com...

>>> =?Utf-8?B?U2FuZHkgV29vZA==?= wrote:

>>> >

>>> > Our network has over 900 XP systems that we need to rename. We're

>> looking for

>>> > a way to script or otherwise automate the process. We need to change a

>> single

>>> > character in the computer name to remove an underscore and replace it

>> with a

>>> > dash. We believe we can vbscript a search and replace script but beyond

>> that

>>> > have only begun to look into the process. Has anyone done anything like

>> this

>>> > before without physically visiting each system?

>>>

>>> Very dangerous to use an automated process for that. You're lible to

>>> toast the entire network.

>>>

>>

>> "lible"? Did you perhaps mean "liable"?

>>

>> Anyway, there are three conceivable outcomes if the OP goes ahead

>> with her automated process:

>> a) It works.

>> b) It does not work and she has to do it manually.

>> c) The renaming works but she has to join the the machines

>> manually to the domain.

>>

>> If you can think of a further scenario then please supply details.

>>

>>


×
×
  • Create New...