Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
SysPrep Phase III - Rename PC & Join Domain Automatically


Bookmark and Share

By: Janis Keim
Posted On: 5/25/2004

SysPrep Phase III - Rename/Join
Rename PC & Join Domain Automatically

Utilizing SysPrep has now eliminated the need to maintain multiple images on a regular basis. By reducing the number of maintained images, errors have also been drastically reduced as a result. In a day and age when we’re being asked to do more work with less available resources, finding a way to eliminate some of the monotonous, repetitive tasks is the next challenge. Two tasks that consume huge amounts of technical support staff’s time are configuring the NetBIOS of a PC and joining a domain, once the workstation has been re-imaged. There are several methods that can be used to accomplish these two very important tasks. This is what we use in our company for automating these two tasks.

Utilities, Scripts, and Registry files
The following files are needed to configure a workstation to rename itself and join a domain without the need for any human intervention. These files are placed into C:\Temp on each base image.

Batch Files Created
  • Firstboot.cmd
  • Secondboot.cmd
Registry Files Created
  • Firstboot.reg
  • Count.reg
SMS Installer File Created
  • Newimage.exe

SysPrep - Rename - JoinDomain Configuration

This is one way of automating the process of renaming a PC and joining a domain. However, some of the items listed below may not be required in your company's environment.
1) Base Image Modifications
    File Structure Modifications
    We add the following files on our base image, all residing in C:\temp.

  • Firstboot.cmd
  • Secondboot.cmd
  • Firstboot.reg
  • Count.reg
  • Newimage.exe
  • Compname.exe
  • Netdom.exe

    Registry Modifications
    We add the following registry modifications in HKLM\Software\Microsoft\WindowsNT\CurrentVersion\WinLogon.

  • Remove Legal Notice Caption (if required by your company)
  • Remove Legal Notice Text (if your company requires this)
  • Configure AutoRestartShell=”1”
  • Configure AutoAdminLogon=”1”
  • Configure Default Password=””
  • Configure DefaultDomainName=”YOURDOMAINNAME
  • Configure AutoLogonCount=3

2) Run SysPrep on a base image with the necessary modifications.
  • Add line to [GuiRunOnce] section to sysprep.inf file (Several changes made to SysPrep.inf)
  • Machine will power off when SysPrep has been run
  • Modified SysPrep.inf
    Changes made from the original SysPrep.inf file (Phase I) to automate renaming the PC and joining a domain (Phase III) are shown in BOLD

    Modified SysPrep.inf file
    ;121103 Last modified Date

    [SysprepMassStorage]
    Primary_IDE_Channel = %windir%\inf\mshdc.inf
    Secondary_IDE_Channel = %windir%\inf\mshdc.inf
    PCMCIA\*PNP0600=%systemroot%\inf\mshdc.inf
    *PNP0600=%systemroot%\inf\mshdc.inf
    PCMCIA\KME-KXLC005-A99E=%systemroot%\inf\mshdc.inf
    PCMCIA\_-NinjaATA--3768=%systemroot%\inf\mshdc.inf
    PCMCIA\FUJITSU-IDE-PC_CARD-DDF2=%systemroot%\inf\mshdc.inf
    *AZT0502=%systemroot%\inf\mshdc.inf
    PCI\CC_0101=%systemroot%\inf\mshdc.inf
    PCI\VEN_10B9&DEV_5215=%systemroot%\inf\mshdc.inf
    PCI\VEN_10B9&DEV_5219=%systemroot%\inf\mshdc.inf
    PCI\VEN_10B9&DEV_5229=%systemroot%\inf\mshdc.inf
    PCI\VEN_1097&DEV_0038=%systemroot%\inf\mshdc.inf
    PCI\VEN_1095&DEV_0640=%systemroot%\inf\mshdc.inf
    PCI\VEN_1095&DEV_0646=%systemroot%\inf\mshdc.inf
    PCI\VEN_0E11&DEV_AE33=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_1222=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_1230=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_7010=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_7111=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_2411=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_2421=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_7199=%systemroot%\inf\mshdc.inf
    PCI\VEN_1042&DEV_1000=%systemroot%\inf\mshdc.inf
    PCI\VEN_1039&DEV_0601=%systemroot%\inf\mshdc.inf
    PCI\VEN_1039&DEV_5513=%systemroot%\inf\mshdc.inf
    PCI\VEN_10AD&DEV_0001=%systemroot%\inf\mshdc.inf
    PCI\VEN_10AD&DEV_0150=%systemroot%\inf\mshdc.inf
    PCI\VEN_105A&DEV_4D33=%systemroot%\inf\mshdc.inf
    PCI\VEN_1106&DEV_0571=%systemroot%\inf\mshdc.inf
    PCI\VEN_8086&DEV_24C3=c:\drivers\infinst\w2k\ich4core.inf
    PCI\VEN_8086&DEV_24C0=c:\drivers\infinst\w2k\ich4core.inf
    PCI\VEN_8086&DEV_244E=c:\drivers\infinst\w2k\ich5core.inf
    PCI\VEN_8086&DEV_24D3=c:\drivers\infinst\w2k\ich5core.inf
    PCI\VEN_8086&DEV_24D0=c:\drivers\infinst\w2k\ich5core.inf
    PCI\VEN_8086&DEV_24DC=c:\drivers\infinst\w2k\ich5core.inf


    [Unattended]
    UnattendedMode = FullUnattended
    OemSkipEula = Yes
    OemPreinstall = No
    updateinstalleddrivers = yes
    DriverSigningPolicy = Ignore

    OemPnPDriversPath = c:\drivers\infinst\w2k;c:\drivers\dpvideo\win2000;c:\drivers\d500vid;c:\drivers\d510vid\win2000;c:\drivers\ibmvideo\win200;c:\drivers\evoaudio\adi\smaxwdm\w2k_xp;c:\drivers\nv_audio\drivers\wdm;c:\drivers\tc_audio\smaxwdm\w2k_xp;c:\drivers\ibmnic\pro100\win2k;

    [GuiUnattended]
    AdminPassword = *
    OEMSkipRegional = 1
    TimeZone = 20
    OemSkipWelcome = 1
    AutoLogon = Yes
    AutoLogonCount = 3


    [UserData]
    FullName = "YOURCOMPANYNAME"
    OrgName = "YOURCOMPANYNAME"
    ComputerName= *
    productid = YOURLICENSEINFO

    [Display]
    ConfigureAtLogon = 0
    BitsPerPel = 16
    XResolution = 1024
    YResolution = 768
    VRefresh = 75
    AutoConfirm = 1

    [Identification]
    JoinWorkgroup = YOURWORKGROUPNAME

    [Components]
    pinball = off
    solitarie = off
    minesweeper = off
    freecell = off

    [Networking]
    InstallDefaultComponents = Yes

    [GuiRunOnce]
    Command0 = "c:\temp\firstboot.cmd"


3) Upload new image
  • To prevent having to start all over again, upload “SysPrepped image” to a server location.

4) SysPrep on New Hardware
  • Power on workstation
  • SysPrep discovers new hardware and installs drivers

5) Beyond SysPrep
  • Workstation reboots
  • Runs C:\temp\firstboot.cmd as configured in sysprep.inf


6) Firstboot.cmd
  • Maps network drive
  • Copies netbios.txt file from server location
    a) Netbios.txt file associates an IP address with a NetBIOS name
    b) This file can remain current by being left on a server share.
  • Runs compname.exe utility which searches for a NetBIOS name based on the current IP address of the machine.
  • Runs shutgui.exe utility to reboot the computer
  • Deletes mapped network drive
  • Adds firstboot.reg file silently to registry
  • PC reboots
  • Firstboot.cmd file contents (shown below)

    Firstboot.cmd
    @echo off
    echo FirstBoot
    net use p: \\\YOURSERVER\YOURSHARE /user:DOMAIN\USERID PASSWORD
    copy p:\netbios.txt c:\temp
    c:\temp\compname /c /file:C:\temp\netbios.txt ?i.?j.?k.?l
    C:\temp\shutgui /l /C /y /t:1 /r
    net use /delete p:
    cmd /c del c:\winnt\system32\$winnt$.inf
    regedit /s C:\TEMP\firstboot.reg
    exit

    Explanations
    1) Compname /c C:\temp\netbios.txt ?i.?j.?k.?l
    Changes the computer name to the one specified
    Searches netbios.txt file for current IP address. Wildcard notation (?) for first, second, third, and fourth octet of the IP address

    2) Shutgui /l /C /y /t:1 /r
    Local machine, force Close applications, answer Yes when prompted to shutdown computer, Time in seconds to shutdown, and Reboots PC.

    3) NetBIOS.txt
    Format of text file looks like:
    192.168.10.134=MYPCNAME
    192.168.10.135=HISPCNAME
    192.168.15.12=HERPCNAME

    NOTE: We update our company-wide netbios.txt file on a bi-weekly basis, unless we’re moving several PCs or obtain new business which would alter this list dramatically.


7) Firstboot.reg
  • HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce key modified by adding “C:\temp\secondboot.cmd”

    a) HKCU used because the command would run before the reboot if it were placed in the HLKM registry hive.
    b) See Firstboot.reg contents (shown below)

    Firstboot.reg
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce]
    @="c:\\temp\\secondboot.cmd"

    Run Secondboot.cmd, for the currently logged on user, after reboot


8) Secondboot.cmd
  • Runs netdom.exe utility to join specified domain
    a) Must reference domain account and password with rights to add a workstation to the domain.
    b) We use a domain test account just for this purpose.
  • Runs C:\temp\newimage.exe
    a) SMS Installer script that reconfigures lanacfg settings and DNS suffix search order.
  • Silently add count.reg into registry
  • Runs shutgui.exe utility to reboot the computer
  • Deletes *.exe, *.reg, and firstboot.cmd files from C:\temp
  • Secondboot.cmd contents (shown below)

    Secondboot.cmd
    @ECHO Off
    setlocal
    Echo SecondBoot
    c:\temp\netdom join %ComputerName% /domain:YOURDOMAIN /userd:YOURDOMAIN\USERID /passwordd:YOURPASSWORD
    c:\temp\newimage.exe
    regedit /s C:\TEMP\count.reg
    c:\temp\shutgui /l /y /t:10 /r
    if exist c:\temp\*.exe del c:\temp\*.exe /f /q>nul
    if exist c:\temp\*.reg del c:\temp\*.reg /f /q>nul
    if exist c:\temp\firstboot.cmd del c:\temp\firstboot.cmd /f /q>nul
    exit

    Explanations
    1) Netdom join /domain: /userd: /passwordd:
    %COMPUTERNAME%
    Environment variable for NetBIOS name
    /domain:
    Domain where PC should be added
    /userd:
    Domain account with rights to add PC to domain
    /passwordd:
    Password for the domain account being used.

    NOTE: The parameters “userd” and “passwordd” are not typos!!

    2) Shutgui /l /y /t:10 /r
    Local machine, answer Yes when prompted to shutdown computer, Time in seconds to shutdown, and Reboots PC.

    3) del c:\temp\*.exe /f /q > nul
    Deletes files in C:\temp directory. This particular line deletes all filenames with a .exe extension
    NOTE: Secondboot.cmd does not get deleted because it is currently in use.

    4) C:\temp\Newimage.exe
    Runs SMS Installer script to reset lanacfg settings and add two DNS suffixes to search order.


9) Count.reg
  • Resets all company specific registry entries back to defaults.
  • Count.reg content (shown below)

    Count.reg
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
    "AutoRestartShell"=dword:00000000
    "DontDisplayLastUserName"="0"
    "AutoAdminLogon"="0"
    "DefaultPassword"=""
    "DefaultDomainName"="YOURDOMAINNAME"
    "AutoLogonCount"=dword:00000000

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system]
    "DontDisplayLastUserName"=dword:00000001
    "LegalNoticeCaption"="PUT LEGAL NOTICE CAPTION HERE"
    "LegalNoticeText"="Put LEGAL NOTICE TEXT HERE”

    1) Resets Registry settings required by our company


10) Newimage.exe
  • Available upon request.


Credits
All SysPrep articles could not have been completed without the hard work of several State Street employees. Henry Duong hmduong@statestreetkc.com, responsible for working with SysPrep initially, ultimately enabled us to reduce the number of images we were maintaining on a regular basis. Without Darren Kirkland’s[email]dekirkland@statestreetkc.com [/email]expertise in coding batch files and spending countless hours testing, we would not be able to automate the process of renaming a PC and joining the domain. And finally, when Henry departed our Help Desk staff for bigger and better opportunities in the Network Services department, Craig Doolin cmdoolin@statestreetkc.com was instrumental in determining how to add brand new hardware into the SysPrep process. Craig and Darren are currently PC Support Specialists at State Street.


  myITforum.com ©2010 | Legal | Privacy