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