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: 1184
Discussions: 200,903, Posts: 2,378,884, Members: 246,272
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,220
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,774
shaik nazeer - have you tried the sugestions posted by cornhusker?
__________________
Have you hugged your kid today??
Steve R Jones is offline   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? (2799)
Is the PSU I received dead? (10)
Install XP pro and a Vista laptop ?.. (8)
California Passes Anti-Flat-HDTV Le.. (38)
A good PSU? (10)
Fox uses old news clips to inflate .. (33)
HIS HD5770 graphic card question (14)
Foreign voltage (5)
New Computer wont recognize XP disc (7)
Dept. of HS: NSA 'Helped' Develop V.. (12)
Print spooler problem (5)
EVGA 9800 gtx help with finding a g.. (6)
Ideal cheap graph card for PC-Gamin.. (14)
Mysterious Boot manager (9)
Recent Discussions
Ideal cheap graph card for PC-Gaming? (14)
HIS HD5770 graphic card question (14)
Install XP pro and a Vista laptop ?? (8)
Need hard disk drivers (3)
Cloning old drive to new drive (6)
Asus P4G8X Mobo (0)
Amptron monitor G17FP-Black (0)
windows vista security holes (0)
EVGA 9800 gtx help with finding a goo.. (6)
A good PSU? (10)
Is the PSU I received dead? (10)
HP Pavillion Laptop ze4220 won't turn.. (7)
Dept. of HS: NSA 'Helped' Develop Vis.. (12)
Foreign voltage (5)
Convert 5 pin Keyboard to USB (11)
Print spooler problem (5)
hybernate option (2)
Steam ID's, Gamertags etc... (1)
New Computer wont recognize XP disc (7)
World's largest Monopoly Game using G.. (328)
Modern Warfare 2: Who Bought It? (60)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (28)
blender help (2)
Hard drive freezes boot (1)
Mysterious Boot manager (9)


All times are GMT -4. The time now is 03:44 AM.
TechIMO Copyright 2009 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