?
Solved

Rename and join domain without rebooting in between.

Posted on 2003-03-04
9
Medium Priority
?
8,892 Views
Last Modified: 2010-08-05
Okay.  In Windows NT 4.0, I was able to rename a PC and then rejoin the domain without rebooting in between the PC rename.  For example, I would finish re-imaging a PC, then rename the PC, then join the domain on a fly.  In Windows 2000 Pro, it doesn't allow me to do that.  Once I rename the PC, I have to reboot.  Then I log back in, and rejoin the domain.  Just wondering if anyone knew of a way or a utility that does the join of the domain in Windows 2000 after the PC is renamed without rebooting in between the renaming and rejoining domain?

Thank you all in advance.

Henry
0
Comment
Question by:yackko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 1

Expert Comment

by:JMansford
ID: 8066088
Annoying isn't it.  Unfortunately I've not found an answer to this.  Therefore I'm adding this response so I get notified of the response.
0
 
LVL 1

Expert Comment

by:JLFitz
ID: 8067929
Since you mention imaging, try using MS's sysprep. For full documentation go here http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windows2000pro/deploy/depopt/sysprep.asp

In short once you have a system ready to image you will run sysprep on it which will shut the machine down. Image system. When the system restarts, you will be presented with a mini-setup wizzard that will allow you to change the pc name and join a domain with only one reboot.
You can even modify the sysprep.ini to provided automated answers.

NOTE: Make sure you have your product key handy because it will ask for it on reboot. (The product key can be put into the sysprep.ini for automation.)
0
 
LVL 1

Expert Comment

by:JLFitz
ID: 8068261
I just verified that name change and domain membership can be changed in one reboot using W2K Pro SP1.

Right click My computer
Select Properties
Select Network Identification Tab
Select Properties
Change Computer Name
Change Domain Membership
Click OK all the way out and reboot.

I took PCname1 in the WORKGROUP, changed it to PCname2 as member of NT4.DOMAIN.ONE, and rebooted.
I then took that same PCname2, changed it to PCname3 as a member of W2K.DOMAIN.ONE, and rebooted.

0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:yackko
ID: 8071992
Well let me clarify.  I'm using SysPrep after the image is done.  SysPrep runs fine, but I don't want it to join the domain when it's done.  So I wrote a script to rename the PC to what it's suppose to be.  Unfortunately it needs to reboot after that.  Then the script fires up again and it use NETDOM to join the domain, then reboot.  What I want to do is to have the script rename the PC and join the domain in one session.  Instead of rebooting in between naming and joining domain.  

I did try to leave the PC in the domain, SysPrep it, burn the image, and load the image on the client machine.  The only problem is SysPrep rips the domain out.  I've tried everything.  Anymore help is appreciated.

Thanks again.
0
 
LVL 1

Expert Comment

by:JLFitz
ID: 8073614
After reading through your previos questions, I have a better understanding of what you're trying to accomplish. I have not done anything like this so all I have left to offer is a couple suggestions.

Try this (if you havn't already):
Have sysprep join domain automaticly with autoname.
(Not sure if reboot will required before running your wsname script for this next step to work?)
Try using the /RCID switch along with the /RDF and /DFK switches. Don't forget the /USER and /PASS switches.

PS: The WSNAME utility looks pretty handy I'll have to check it out.
0
 
LVL 1

Author Comment

by:yackko
ID: 8073740
Yeah the WSNAME is a pretty good utility.  It works great, but not in a script.  I've tried all the switches, but none work.  I did find another utility that is a little bit better within a script.  It's "Compname" and you can find it at http://www.willowhayes.co.uk/.  Really nice utility and nice author.

I'm found this script but just wondering how I can incorporate one of these rename and rejoin util into the WSH script?  For "Compname" to look for the data text file the syntax is: Compname /c /file:c:\netbios.txt ?i ?l ?k ?j

The ?i ?l ?k ?j is the look up param which is using the IP to look up the netbios name in the text file.  Here is the script I found:

'==========================================================================
'
' VBScript Source File
'
' NAME: computer_rename.vbs
'
' AUTHOR: Bradly T. Bolin
' DATE  : 4/5/2001
'
' COMMENT: Removes computer from an NT domain, renames it, then rejoins it
'  Requires NETDOM.EXE from Windows 2000 Resource Kit
'
'==========================================================================

Option Explicit      

Dim oFileSystem 'Scripting Dictionary object
Dim oWshShell 'Windows Script Host Shell object
Dim sCurrentName 'holds computername environment variable
Dim oWshEnvironment 'Windows Script Host environment object
Dim sTempDir 'temporary directory of computer on which comprename.vbs is run
Dim sPHASE 'holds number indicating PHASE in rename operation
Dim sProgram 'name of this script
Dim sProgramDir 'Path to this script

Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oWshShell = CreateObject("WScript.Shell")
Set oWshEnvironment = oWshShell.Environment("Process")


sCurrentName = oWshEnvironment("COMPUTERNAME")
sTempDir = oWshEnvironment("TEMP")
sProgram = "computer_rename.vbs"
sProgramDir = oFileSystem.GetAbsolutePathName(".")

On Error Resume Next

sPHASE = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Phase")

Select Case  sPHASE
      Case ""
            Call REMOVE 'Subroutine
      Case "1"
            Call REJOIN 'Subroutine
End Select
      
'Restart computer
Dim OpSysSet, OpSys
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Reboot()
Next
WScript.Quit
      
'REMOVE Subroutine:  Remove computer from domain, rename it and restart it

Sub REMOVE
      'Create Dictionary (key: Name, item: NewName) and load data into it
      Dim oCompName, oTextStream, sArray, sLine, sNewName
      Dim oDictionary 'VBScript Dictionary Object
      
      Set oDictionary = CreateObject("Scripting.Dictionary")
      Set oCompName = oFileSystem.GetFile(sProgramDir & "\" & "compname.txt")
      Set oTextStream = oCompName.OpenAsTextStream(1)

      Do While Not oTextStream.AtEndOfStream
            sLine = oTextStream.ReadLine
            sArray = Split(sLine, " = ", -1, 1)
            ' sArray(0) contains NAME.
            ' sArray(1) contains NEWNAME.
            oDictionary.Add sArray(0), sArray(1)
            Loop
               oTextStream.Close
      
      'Abort if computer is NOT in list of those to be renamed
      If oDictionary.Exists(sCurrentName) = FALSE Then
            MsgBox("Error")
            WScript.Quit
      End If
      'It's OK to proceed, so retrieve new computer name and place in variable sNewName
      sNewName = oDictionary.Item(sCurrentName)
      'Copy files necessary for the rename operation to local machine
      oFileSystem.CopyFile sProgramDir & "\" & sProgram, sTempDir & "\" & sProgram
      oFileSystem.CopyFile sProgramDir & "\" & "NETDOM.EXE", sTempDir & "\" & "NETDOM.EXE"
      'Backup user logon name to PreviousName value
      Dim sUserName
      sUserName = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName")
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\PreviousUser", sUserName
      'Increment PHASE value
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Phase", 1
      'Place reference to program in RunOnce key
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RUN_RENAME", sTempDir & "\" & sProgram
      'Enable AutoAdminLogon
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", 1
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "XXX"
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", "XXX"
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", sNewName

      'Execute NETDOM REMOVE
      oWshShell.Run sTempDir & "\" & "NETDOM.EXE REMOVE " & sCurrentName & " /D:XXX /Ud:XXX /Pd:XXX", 1, TRUE
      'Rename computer
      oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName", sNewName
      oWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname", sNewName
End Sub

'REJOIN Subroutine: Rejoin computer to the domain and clean some stuff up

Sub REJOIN
      'Restore previous user logon name from PreviousUser Value
      Dim sUserName
      sUserName = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\PreviousUser")
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", sUserName
      'Delete PHASE value
      oWshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Phase"
      'Disable AutoAdminLogon
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon", 0
      oWshShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword"
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", "XXX"
      'Place clean-up routine in RunOnce key
      Dim sCMD
      sCMD = "c:\winnt\system32\"
      oWshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RUN_CLEANUP", sCMD & "CMD.EXE /c DEL " & sTempDir & "\" & sProgram
      'Execute NETDOM JOIN
      oWshShell.Run sTempDir & "\" & "NETDOM.EXE JOIN " & sCurrentName & " /D:XXX /Ud:XXX /Pd:XXX", 1, TRUE
End Sub

======================================================
Thanks again in advance.
0
 
LVL 1

Accepted Solution

by:
JLFitz earned 150 total points
ID: 8073852
After reading through your previos questions, I have a better understanding of what you're trying to accomplish. I have not done anything like this so all I have left to offer is a couple suggestions.

Try this (if you havn't already):
Have sysprep join domain automaticly with autoname.
(Not sure if reboot will required before running your wsname script for this next step to work?)
Try using the /RCID switch along with the /RDF and /DFK switches. Don't forget the /USER and /PASS switches.

PS: The WSNAME utility looks pretty handy I'll have to check it out.
0
 
LVL 1

Expert Comment

by:JLFitz
ID: 8073961
RE: comment by me posted at 03/05/2003 10:40AM PST

Don't know how that got posted a second time? Maybe when I refreshed the page to see yacko's comment.
0
 
LVL 1

Author Comment

by:yackko
ID: 8427955
Found a solution to the problem.  Thank you all for your help.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question