home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > General Tech Discussion
Ask a Tech Support Question (free)!

script to change computer name

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2589
Discussions: 200,524, Posts: 2,374,513, Members: 245,845
Old September 3rd, 2002, 11:55 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Mar 2002
Posts: 65
script to change computer name

Does anyone have a good batch file or VB script that can change a computer name and rejoin the domain?

Thanks
cornhusker is offline   Reply With Quote
Old September 4th, 2002, 12:25 AM     #2 (permalink)
addicted
 
DVNT1's Avatar
 
Join Date: Oct 2001
Location: Ohio
Posts: 6,103
I haven't done that but part of the solution would be to use the NETDOM tool (MS Resource kit)

Quote:
you can remove a computer from the command line using the Resource Kit utility NETDOM

netdom /Domain:<domain> MEMBER <machine name> /delete
e.g. netdom /Domain:savilltech MEMBER kevinpc /delete

You can use this command from any machine workstation or server as long as you are logged on as an administrator. When you enter the command it will find the PDC and delete, the output is as follows:

Searching PDC for domain SAVILLTECH ...
Found PDC \\PDC
Member \\KEVINPC successfully deleted.

DVNT1 is offline   Reply With Quote
Old September 15th, 2002, 11:13 AM     #3 (permalink)
Member
 
Join Date: Mar 2002
Posts: 65
There are three different batch files attatched that will remove a windows NT and W2K computer from a domain, then, rename a pc, and finally rejoin a windows NT and W2K pc to the domain. The batch files use psexec for remote control and two utilities (reg.exe and shutdown.exe)

I am aksing for you input and advise on how to make these batch files and the whole process run a little smoother. The process with the three reboots takes about 6-8 minutes to complete. I understand that I could use a VB script to do this, however, at this time I do not know VB language. This is why I am working with batch files.

Thanks, all input is welcomed


Pre-requirements to renaming a pc remotely on your computer.
1.copy Pstools folder, located on \\servername, to the root of your c:\
2.identify the computer name you wish to change

Step I. go to cmd.exe

Step II. Pstools\psexec \\(computername) ipconfig /all
-make a note of the ip address for future reference

Step III. Pstools\psexec \\(computername) c:\winnt\system32\reg.exe
-
Step IV. Pstools\psexec \\(computername) –c remove.bat
-remote pc will reboot. ping –t (ip address)
::Removes the pc from its current domain.

Echo Which Domain do you want to be removed from? A=domainname#1, B=domainname#2
choice /c:AB
If %ERRORLEVEL% EQU 1 goto domainname#1
if %ERRORLEVEL% EQU 2 goto domainname#2


:domainname#1
echo Removing from domainname#1.
NetDom remove %Computername% /Domain:domainname#1 /UserD:username /PasswordD:usernamepassword
goto end

:domainname#2
echo Removing from domainname#2.
NetDom remove %Computername% /Domain:domainname#2 /UserD:username /PasswordD:usernamepassword
goto end

:end
shutdown /l /r /y /t:1


Step V. Modify rename.bat: Use notepad find and replace to change the newcomputername the four different places it occurs to the new name you wish to give the computer. Use Server Mang. for a reference.

Pstools\psexec \\(ip address) –u (local admin) –p (local admin password) -c –f rename.bat
-remote pc will reboot. ping –t (ip address)

reg update "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Para meters\Hostname=newcomputername"
reg update "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Para meters\NV Hostname=newcomputername"
reg update "HKLM\SYSTEM\CurrentControlSet\Control\ComputerNam e\ActiveComputerName\ComputerName=newcomputername"
reg update "HKLM\SYSTEM\CurrentControlSet\Control\ComputerNam e\ComputerName\ComputerName=newcomputername"


reg delete hkcr\clsid\{20d04fe0-3aea-1069-a2d8-08002b30309d}\localizedstring /force
reg add "hkcr\clsid\{20d04fe0-3aea-1069-a2d8-08002b30309d}\localizedstring=My Computer %%computername%%" reg_expand_sz
reg add "hklm\software\microsoft\windows\currentversion\po licies\system\dontdisplaylastusername=1" reg_dword
reg update "hklm\software\microsoft\windows\currentversion\po licies\system\dontdisplaylastusername=1"


:end
shutdown /l /r /t:1 /y

Step VI. Pstools\psexec \\(ip address) –u (local admin) –p (local admin password) –c –f addtodomain.bat

:: Adds the computer to domain

Echo Which Domain do you want to join? A=domainname#1, B=domainname#2
choice /c:AB
If %ERRORLEVEL% EQU 1 goto domainname#1
if %ERRORLEVEL% EQU 2 goto domainname#2

:domainname#1
echo Adding to domain domainname#1.
username join %Computername% /Domain:domainname#1 /UserD:username /PasswordD:usernamepassword
goto end

:domainname#2
echo Adding to domain domainname#2.
username join %Computername% /Domain:domainname#2 /UserD:username /PasswordD:usernamepassword
goto end

:end
shutdown /l /r /t:1 /y
cornhusker is offline   Reply With Quote
Old April 29th, 2008, 09:32 AM     #4 (permalink)
Junior Member
 
Join Date: Apr 2008
Posts: 3
i too have same prob. can any one tell the solution
shaik nazeer is offline   Reply With Quote
Old April 29th, 2008, 09:48 AM     #5 (permalink)
Ultimate Member
 
Big_Daddy's Avatar
 
Join Date: Oct 2004
Location: Blacksburg, VA USA
Posts: 1,200
Does your domain require a password to join?
Big_Daddy is offline   Reply With Quote
Old April 29th, 2008, 10:03 AM     #6 (permalink)
Junior Member
 
Join Date: Apr 2008
Posts: 3
yes...
can u pls tell how to run the batch files too...
shaik nazeer is offline   Reply With Quote
Old April 29th, 2008, 10:30 AM     #7 (permalink)
Ride 'em Cowboy
 
Join Date: Oct 2001
Location: Dallas, TX
Posts: 8,703
shaik nazeer - have you tried the sugestions posted by cornhusker?
__________________
Have you hugged your kid today??
Steve R Jones is online now   Reply With Quote
Old April 29th, 2008, 10:39 AM     #8 (permalink)
Junior Member
 
Join Date: Apr 2008
Posts: 3
Steve - can u pls tell how to run the batch files with the corresponding name
shaik nazeer is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (1661)
FT HOOD attack: 7 killed 12 injured (70)
HELP!!! What do you think of this s.. (25)
windows 7 retail and rtm (5)
Review My Build (6)
My 1st pc build (40)
Looking for a graphic card that wil.. (30)
PC Modern Warfare 2: it's much wors.. (13)
core i7 extreme 975, nvidia 9400gt (9)
Building my first computer (13)
[F@H SPAM 11/1/09]New month . . . n.. (34)
Aero in Vista (7)
slaving laptop drive (7)
Internet very slow since updating A.. (10)
Recent Discussions
thefeedwater.com VIRUS (0)
Images won't load on Opera (12)
Help and Support disappeared from my .. (1)
hi-grade laptop (0)
PC Modern Warfare 2: it's much worse .. (13)
higrade black screen (0)
Dell 8300 Graphics Problems (2)
[F@H SPAM 11/08/09] Where has all the.. (2)
Which monitor should I get? (13)
nvidia geforce 9500GT 1gig DDR2 (3)
[F@H SPAM 11/1/09]New month . . . new.. (34)
Endless BSOD to Recovery Manager loop.. (0)
HELP!!! What do you think of this sys.. (25)
New Processor, Monitor will not turn .. (3)
Determining ip route and serial addre.. (8)
can u beat freecell # 1941? (11)
I have words with double underlines a.. (2)
Internet very slow since updating AVG.. (10)
My Pc wont start after i interupted D.. (0)
windows 7 retail and rtm (5)
New processor technical problem (0)
boot from CD-ROM in chipset via P4M80.. (2)
Powe Director v8 (0)
Windows Experience Index is screwed u.. (3)
Review My Build (6)


All times are GMT -4. The time now is 04:38 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28