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: 1428
Discussions: 195,830, Posts: 2,327,805, Members: 241,356
Old September 3rd, 2002, 10: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 3rd, 2002, 11:25 PM     #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, 10: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, 08: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, 08:48 AM     #5 (permalink)
Ultimate Member
 
Big_Daddy's Avatar
 
Join Date: Oct 2004
Location: Blacksburg, VA USA
Posts: 1,150
Does your domain require a password to join?
Big_Daddy is offline   Reply With Quote
Old April 29th, 2008, 09: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, 09:30 AM     #7 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Location: Dallas, TX
Posts: 7,958
shaik nazeer - have you tried the sugestions posted by cornhusker?
Steve R Jones is offline   Reply With Quote
Old April 29th, 2008, 09: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
Budget PC Build, first time - Need .. (13)
Is It Just Me? (1416)
Looking for Some good PC games. (6)
Palin Resigning as Governor (24)
4gb RAM (6)
[F@H SPAM 28 JUN 09] Today's the da.. (132)
This is a first: US/allies allowed .. (6)
Worth upgrading GFX card? (33)
Crap, my graphics have gone to hell (17)
You guys might like this one (22)
New Computer Build (5)
Is this a decent gaming system??? (25)
Building PC for learning experience (18)
Need build parts or cheap computer (13)
Recent Discussions
Budget PC Build, first time - Need Ad.. (13)
Worth upgrading GFX card? (33)
xp boot problem (0)
Looking for Some good PC games. (6)
Toshiba Tecra A8 / Satellite pro A120.. (5)
Brief pauses every few seconds on new.. (3)
Gigabyte 770 vs 790GX (cant decide) (4)
Swapping computers (1)
Need Technical Expierience (75)
Dell Dimension 3000 wont start proper.. (0)
need a laptop (3)
No signal to monitor at boot (4)
Trying to OC E7200 as much as possibl.. (1)
Online Storage (4)
[F@H SPAM 28 JUN 09] Today's the day... (132)
SAA7130 TV Card (98)
Battlefield 2 Installation ERROR !! (10)
4gb RAM (6)
FS: Used Black Motorola RAZR V3 (No C.. (3)
You guys might like this one (22)
New Computer Build (5)
GPU Install Issues (1)
Automatic Shutdown (2)
how do i connect a samsung lcd tv to .. (0)
Musical Maxtor (259)


All times are GMT -4. The time now is 02:02 AM.
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