how make sysprep promt to enter a computer name?

Proposed how make sysprep promt to enter a computer name?

  • Wednesday, January 31, 2007 7:47 PM
     
     

    I am working in a lab enviroement creating Vista images using Norton Ghost 7.5. I have created an answerfile using AIK. However, I am unable to configure that answerfile to prompt the user for a computer name. A random name is automaticly generated. Can anyone please assist me with this? I pasted the answerfile below.

     

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="oobeSystem">
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <FirstLogonCommands>
                    <SynchronousCommand wcm:action="add">
                        <Order>1</Order>
                        <CommandLine>net user administrator /active:yes</CommandLine>
                    </SynchronousCommand>
                </FirstLogonCommands>
                <OOBE>
                    <NetworkLocation>Work</NetworkLocation>
                    <HideEULAPage>true</HideEULAPage>
                    <SkipMachineOOBE>false</SkipMachineOOBE>
                    <SkipUserOOBE>true</SkipUserOOBE>
                    <ProtectYourPC>1</ProtectYourPC>
                </OOBE>
                <UserAccounts>
                    <AdministratorPassword>
                        <Value>aQBzAHQAbABhAGIAMgAxAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
                        <PlainText>false</PlainText>
                    </AdministratorPassword>
                </UserAccounts>
                <VisualEffects>
                    <FontSmoothing>ClearType</FontSmoothing>
                </VisualEffects>
            </component>
        </settings>
        <settings pass="windowsPE">
            <component name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <UserData>
                    <AcceptEula>true</AcceptEula>
                    <FullName>iststudent</FullName>
                    <Organization>Penn State</Organization>
                </UserData>
                <EnableFirewall>true</EnableFirewall>
                <EnableNetwork>true</EnableNetwork>
                <Restart>Restart</Restart>
                <UseConfigurationSet>true</UseConfigurationSet>
            </component>
        </settings>
        <settings pass="specialize">
            <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Identification>
                    <Credentials>
                        <Domain>istlab.com</Domain>
                        <Password>**********</Password>
                        <Username>iststudent</Username>
                    </Credentials>
                    <JoinDomain>istlab.com</JoinDomain>
                    <UnsecureJoin></UnsecureJoin>
                </Identification>
            </component>
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
                <RegisteredOrganization>Penn State</RegisteredOrganization>
                <RegisteredOwner>iststudent</RegisteredOwner>
                <TimeZone>Eastern Standard Time</TimeZone>
                <ComputerName></ComputerName>
            </component>
        </settings>
        <settings pass="generalize">
            <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
            </component>
        </settings>
        <cpi:offlineImage cpi:source="wim://istlabd18/test/test.wim#test" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>

All Replies

  • Wednesday, January 31, 2007 8:40 PM
     
     Proposed
    The pass for computer name is under

    Components>Microsoft-Windows-Shell-Setup>Computer name

    You have to add the entire Shell Setup Pass into your answer file, and the computer name, along with several other things will be an option on the right panel, when Shell Setup is highlighted in the main panel. 

    I have a screen shot if you need it. Hope this helps.



    • Proposed As Answer by Ryan.Moon Thursday, September 29, 2011 7:47 PM
    •  
  • Wednesday, January 31, 2007 8:58 PM
     
     
    thanks, but I need sysprep to prompt me for a computer name which it does not do. The image is being loaded to several systems they all need seperate names.
  • Wednesday, January 31, 2007 9:06 PM
     
     
    This is from the Unattend.chm file:


    Computer Name:

    Specifies the computer name used to access the computer from the network. If ComputerName is empty or missing, the user must enter a computer name in Windows Welcome.

    If you set this value to an asterisk (*), a random computer name is generated. This random name has at most 8 characters from the RegisteredOwner and/or RegisteredOrganization strings plus random characters.

    Computer_name is a string with a maximum length of 15 characters

    If that doesn't work alone, try putting the pass into the oobe pass or the auditSystem or auditUser passes.

    Hope this helps, more...lol
  • Thursday, February 01, 2007 4:21 AM
     
     Proposed

    Looks like you're using an UnattendJoin.  I hate to say it, but no matter what you do with the computername setting it will never prompt you during the Specialize phase.  It will however prompt you in the OOBE phase, but that creates all kinds of problems since the computer has already been joined to the domain with a randomly generated name.

    Here's the info I shared from another thread.

    I spoke with MS PSS about this and they've admitted it is a bug.  As you discovered, even if you leave the computer name field blank it still automatically generates a name, joins it to the domain, and prompts you again to change only the local name during the OOBE phase thus severing the trust relationship for the domain account.

    As I understand it they're talking a lot of calls on this and are actively looking at a permanent fix.  In the meantime, you can workaround this issue by using an Autologon and running a script in FirstLogonCommands section under oobe System .  So in other words, let it create the computer name for you, join it to the domain, but use the script to rename the machine account.  I've posted some sample code below.

    Good luck - jb

    Const JOIN_DOMAIN = 1

    Const ACCT_CREATE = 2

    Const ACCT_DELETE = 4

    Const WIN9X_UPGRADE = 16

    Const DOMAIN_JOIN_IF_JOINED = 32

    Const JOIN_UNSECURE = 64

    Const MACHINE_PASSWORD_PASSED = 128

    Const DEFERRED_SPN_SET = 256

    Const INSTALL_INVOCATION = 262144

    Password = "Your Password"

    Username = "Domain\Username"

    Name = InputBox("Please enter a computer name:", "Rename Computer")

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

    For Each objComputer in colComputers

    err = objComputer.Rename(Name, Password, Username)

    If Err.Number = 0 Then

    WScript.Echo "Successfully renamed computer to " & name & "!"

    WScript.Echo "System will now restart for change to take effect!"

    Call Restart

    Else

    WScript.Echo "An error occurred renaming the computer!"

    WScript.Echo "Error Number: " & Err.Number

    WScript.Echo "Error message: " & Err.Description

    End If

    Next

    Sub Restart

    Dim wshShell

    Set wshShell = CreateObject("WScript.Shell")

    wshShell.Run "%WINDIR%\System32\shutdown.exe /r /t 0 /f /d p:2:4", 0

    End Sub

     

  • Friday, February 02, 2007 5:19 AM
     
     
    I wonder if there is any progress on this topic. I have seen a lot of different forums with this same problem. And I am running into this problem as well. I wrote a script that goes into active directory and gets the computer name based on the guid for the object. But... you cannot get that name unless the computer is already in the domain. So i guess you could use this script and save the name to a file, then kick the computer out of the domain and reboot. Then rename and re-enter the domain. But thats semi irritating. I don't see why it doesn't just name the computer the same as the AD object you already made. Especially since it has the netbootGUID in the objects properties.
  • Friday, February 02, 2007 3:12 PM
     
     
    This is probably an overkill for you but what we've done for our Vista pilot is create a HTA script that loads in PE and the user specifies the computer name, domain join credentials, time zone, etc.  These settings are written into the unattend file and this is then passed via the /unatted:file.xml switch to setup.exe.
  • Saturday, February 03, 2007 2:34 AM
     
     
    I don't suppose you would be willing to post your script with maybe a how-to along with it. I think that would come in handy if it works. Because my method doesn't work at all.  
  • Wednesday, February 14, 2007 2:00 AM
     
     Proposed

    NOTE: This method is NOT supported by Microsoft - so be aware that you do this at your own risk!

    That being said, here is what I do to prompt the user for settings, such as ComputerName on Sysprep'ed images...

    1. Create C:\Sysprep.xml with strings to replace:
        EXAMPLE:
        <settings pass="specialize">
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="
    http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>
                <RegisteredOwner>SomePerson</RegisteredOwner>
                <RegisteredOrganization>SomeOrg</RegisteredOrganization>
                <TimeZone>Pacific Standard Time</TimeZone>
            </component>
        </settings>

    2. Create a VBScript to:
      a. prompt the user for the values you want to specify (such as ComputerName)
      b. perform a string replace with those values in the C:\Windows\Panther\unattend.xml file (NOTE: not in C:\Sysprep.xml)
      c. launch windeploy.exe to start the setup process

    ' ----- Begin sample: C:\Scripts\EditUnattend.vbs -----
    Option Explicit
    Dim answer, computerName, unattendFile, WshShell, fso, unattendFileObject, strContents

    unattendFile = "C:\Windows\Panther\unattend.xml"

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")

    Do While answer <> vbYes
       computerName = InputBox("Enter the desired Computer Name:", "Computer Name")
       answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & computerName, vbYesNo, "Verify Name")
    Loop

    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
       'Read the unattend file in and replace apprpriate variables
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
       strContents = unattendFileObject.ReadAll
       strContents = Replace(strContents, "
    _COMPUTERNAME_REPLACE_
    ", computerName)
       unattendFileObject.Close

       'Write the updated contents back to the unattend file
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
       unattendFileObject.Write(strContents)
       unattendFileObject.Close
    End If

    ' Launch setup (will use the modified unattend.xml)
    WScript.Sleep 5000
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True

    ' ----- End sample: C:\Scripts\EditUnattend.vbs -----

    3. Run sysprep, but do not shutdown yet (in an elevated cmd.exe)
    sysprep.exe /oobe /generalize /unattend:C:\Sysprep.xml /quit

    4. Modify the HKLM\System\Setup 'CmdLine' registry value to launch C:\Scripts\EditUnattend.vbs
    reg add HKLM\System\Setup /v CmdLine /t REG_SZ /d "cmd /c cscript //nologo C:\Scripts\EditUnattend.vbs" /f

    5. Shutdown the system and capture the image using whatever imaging software you use

    When you start up this image, the vbscript should run and prompt the user for input - it will then edit the unattend.xml using that input and then launch windeploy.exe to finish setup with these settings.

    You should be able to do this for any values in the Sysprep.inf file.  Just make sure you use unique strings to search and replace on.

    My actual EditUnattend.vbs script has some extra features - such as verifying the name entered is netbios naming compliant and generating a pseudo-random name if none is specified.

    I hope this helps,

    Mike_EEC [MSFT]

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

     

    • Proposed As Answer by DTE-ITGuy Thursday, June 24, 2010 9:59 PM
    •  
  • Thursday, February 22, 2007 6:11 PM
     
     
    Is there a real fix for this yet? Not way to just have the computer get its name from AD and Join the domain? I wrote a script, that successfully gets the computer name from AD based on the GUID and then names the computer, but it cannot be in the domain, and then after you reboot you have to run it again and it will join you to the domain (but you could just do that manually just as fast). I think it would be really cool if microsoft would come out with a fix for this problem.
  • Friday, February 23, 2007 6:28 PM
     
     
    Here is a good question. Is there anyway that I can run my script during the WinPE Session and have it write the correct computer name to the unattend.xml before it joins the computer to the domain? So before the Specialize phase I want to run a VbScript that Connects to Active Directory, Gets the Correct name of the computer (based on the netbootGUID) and then Writes the correct name into the Unattend file before the computer name gets written to the computer.
  • Wednesday, February 28, 2007 7:34 PM
     
     Proposed

    I'm not an expert, but I believe if you use WDS to deploy your images, it lets you pre-stage your machines in AD and should do everything you need in a single pass.

    You might want to start a new thread to get more traction as the subject of this thread is just about prompting for a computer name.

    Mike_EEC [MSFT]

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

  • Thursday, March 01, 2007 8:35 PM
     
     

    Doug, not sure if this helps, but I wrote a blog post on manipulating unattend files programmatically:

    http://shellrevealed.com/blogs/shellblog/archive/2006/11/06/Part-4-Dr.-Unattend_3A00_-Programmatically-manipulating-unattend-answer-files.aspx

  • Friday, March 02, 2007 7:17 PM
     
     
    Thanks Mike!  I was able to get a working imaging solution together using your script.  I had to tweak my unattend file a bit to get everything we wanted, but the key was your script to allow us to input the desired machine name.  Thanks again!

    Steve
  • Wednesday, March 14, 2007 8:24 PM
     
     
    Bilal Aslam
    I was unable to complete your guide, as I cannot make a custom Win PE 2.0 that will boot up like the one does by default from WDS (the one that lets you chose an image and such). You probably know how to do this, so maybe if you can help with that i can get this whole thing working. Because it sounds like, from your guide at least, that you have a very similar situation to what im doing.     
  • Thursday, March 15, 2007 2:21 AM
     
     
    A huge script just to do one thing that was easy to do in XP. Does anybody else think this is insanity?

    Maybe they forgot that some people don't need out of box experiences.
  • Thursday, March 15, 2007 5:00 PM
     
     
    I do. It is something that the prestaging of computers fixes, but only if you do not include an answer file. If you attach an answer file to the image then it doesn't name the computer correctly. I am still trying to find a way around this problem.  
  • Thursday, March 29, 2007 4:02 PM
     
     
    I removed the <ComputerName></ComputerName> completely under the specialize section and it prompted for the Computername.
  • Thursday, April 26, 2007 11:04 AM
     
     

    hello stephen,

    i am working with WDS and i have problem in providing computername and joining to domain with my desired computer name....i m really tired...

    I am not an expert..but only possible solution will be the way you have done your setup...

    i mean running script on firstlogon..i will be please if you can provde me your unattended.xml file...i dont understand..wht path to specify for Commandline in Firstlogon ...please email me or post your complete script....

    i will appreciate your help.,

     

    regards,

    riz

  • Thursday, October 25, 2007 7:57 PM
     
     

    I have tried this and it does not work for me.  The documentation still states to leave the field blank and it will prompt you.  Is there a known fix for this yet?  All I want is a prompt not an automatic name that Vista gives it.

  • Wednesday, November 19, 2008 7:57 AM
     
     

    It would be easier to use MySysprep 2 at http://www.tsaysoft.com/mysysprep2

     

    1. Copy MySysprep.exe to C:\Windows\System32\sysprep

    2. Edit your sysprep.xml and use any string you like enclosed by %. For example

    <ComputerName>%Please input a computer name%</ComputerName>

    3. Use MySysprep.exe instead of Sysprep.exe. For example,

    mysysprep.exe /oobe /generalize /shutdown /unattend:C:\Sysprep.xml

     

  • Sunday, December 14, 2008 6:25 AM
     
     
    Reply to Matt Helander - Posted on Wednesday, January 31, 2007 3:40:09 PM

     Yeah, but when you add the entire "Microsoft-Windows-Shell-Setup_Neutral" component and you don't populate/change the values, the validation flags this a a warning and ends up not writing any of them to the answer-file.

    What was the point of adding the entire component and not just the property-values wished to be changed?

    Thanks
  • Sunday, December 14, 2008 7:47 AM
     
     
    Reply to Mike_EEC - Posted on Tuesday, February 13, 2007 9:00:10 PM

    SSSWWEEEEETT...it worked like a charm!!

    I won't say how long I've been troubleshooting this problem, only to have found this workaround (at 2:45am)...and have it work the very FIRST time I tried it.  How often does that happen?

    Awesome...I need to write this date down in my Bible!!
  • Wednesday, December 17, 2008 1:48 AM
     
     

     Gday Guys,

    I to have been battling with this for a while now and came up wth my own work around wich allows you to add custom scripts to a sysprepped image. You can check that out on my blog 

    But this way is FANTASTIC. I have just tested with prompting for a Computer Name and also promting for a domain user name to add to the local administrators group, add that works a treat as well.

    GOLD!!!!!!

  • Thursday, March 26, 2009 8:31 PM
     
     
    I am trying to use mysysprep to sysprep a a system, and it's not working right.

    Basically, here is my problem. I want to be able to image a computer. At first boot, I want to enter a computer name, have the computer bind itself to our domain, and log in to windows ready to use.

     

    The way I have it set up now, if I run mysysprep and reboot, it works flawlessly; but, if I run mysysprep, shut down, make an image of the PC using Imagex and restore that image onto the same or another identical computer, it doesn’t work at all. It’s almost like mysysprep doesn’t use the answer file when the computer is imaged to another system.


    There is no difference, other than using imagex to make an image and restore an image. i've tried it over and over, and i keep having the same result. It doesn't matter whether or not i restore the image onto the same computer or a different model of the same system.

    Any Ideas?
  • Thursday, April 02, 2009 8:12 PM
     
     
    Never mind. Figured it out. It was a problem with my WDS server. For each Vista image, you have to go to properties for the image on the WDS server and click the checkbox for "allow image to install in unattended mode" and point it to a copy of your answer file.
  • Friday, September 04, 2009 5:15 PM
     
     
    I am in windows7 and this thread was my last hope, I followed the instructions for the script.

    Everything seemed to work but unfortunately it looked like sysprep named the PC before the script could change the unattend.xml.

    Did something change in Windows 7 now that it changes the name before the PC reboots or what?
  • Wednesday, September 16, 2009 5:34 AM
     
     
    I had the same issue. I tried again with the /generalize switch with MySysprep2 and it worked like a charm. Give that a shot.
  • Thursday, February 25, 2010 4:23 PM
     
     
    I don't know if anyone has solved this but what I did was in the unattend.xml file delete the computername line.  This will prompt for a computer name at that point.
    Andy
  • Friday, March 26, 2010 8:58 PM
     
     

    Mike,

     

    Looks like a great post.  I am trying to follow your instructions here.  If you are able to help out that would be awesome.  I really want to rename the machine PRIOR to joining the domain as I know others do as well.  Will the above script/hack do this for me on Windows 7?  I tried it yesterday though I got confused on where exactly you are placing the sysprep.xml files.  Any suggestions?

    Thanks,

    Dan Christ

  • Monday, March 29, 2010 1:41 PM
     
     

    Dan,

    That sysprep.xml file will be added to the image in WDS.  If you right click your image in WDS and select properties you can browse to your sysprep.xml file and add it to your image so that your image will pull from it.  It will then create an unattended.xml file that is associated with your image and place it inside a folder within your group.  We have our windows 7 image that prompts us for a name and joins the domain.

     

    Andy

  • Monday, March 29, 2010 3:59 PM
     
     

    Andy,

     

    Thanks for the reply.  I was referring to Mike_EEC posting above.  I was confused about the locations of all the sysprep files he referred to.  In step 1 it says:  "Create C:\Sysprep.xml with strings to replace:...."  This to me says to place the sysprep.xml file at the root of C.   Then in step 2 it says "perform a string replace with those values in the C:\Windows\Panther\unattend.xml file (NOTE: not in C:\Sysprep.xml)".   This to me says to place the Sysprep.xml file in the "C:\windows\panther\" path.     

    Also, as you state, to apply the sysprep file to the image in WDS.  I understand that portion.  So, IF I place my sysprep.xml file in the pather folder and also apply it to the image, I'm OK?   I'll be testing this.

    Thanks,

     


  • Monday, March 29, 2010 4:21 PM
     
     

    Dan,

    You can create your sysprep.xml file anywhere.  We save all of ours on a network share.  We just name them based off of the machine that we are creating the image for and we call our universal one unattended.xml.  I also create the .xml file on my local machine and just save it to the desktop, then put it in our network share.

    Andy

  • Monday, March 29, 2010 4:21 PM
     
     

    Dan,

    You can create your sysprep.xml file anywhere.  We save all of ours on a network share.  We just name them based off of the machine that we are creating the image for and we call our universal one unattended.xml.  I also create the .xml file on my local machine and just save it to the desktop, then put it in our network share.

    Andy

  • Monday, March 29, 2010 4:22 PM
     
     

    Dan,

    You can create your sysprep.xml file anywhere.  We save all of ours on a network share.  We just name them based off of the machine that we are creating the image for and we call our universal one unattended.xml.  I also create the .xml file on my local machine and just save it to the desktop, then put it in our network share.

    Andy

  • Wednesday, August 04, 2010 12:29 PM
     
     

    Hi,

    I am using MySysprep2 and imaged a machine, uploaded it to my WDS server and attached the sysprep.xml file to the image. But for some reason when i select the image it dosent propmpt me to add a computer name.

    when i try the same thing on a client using:

    MySysprep /generalize /oobe /shutdown /unattend:c:\sysprep.xml

    when i restart the PC it works fine the machine is prompts me for a computer name. Am i doing something wrong on the server becuase a prestaged name is still being generated.

    Thanks

    Jay

  • Wednesday, September 15, 2010 3:37 PM
     
     Proposed

    Jay20101,

    Please read the entire post from top to bottom and follow the steps under Mike_EEC. I've used it and everyone else here has and it works perfectly for both Vista (x86/x64) & Windows 7(x86/x64). First thing first - Stop using MySysprep.exe we are not using it here, we are using the sysprep.exe that came with the OS. Create the EditUnattend.vbs script as described, edit your sysprep.xml using the ‘_COMPUTERNAME_REPLACE_' in the computer name filed and run the sysprep /generalize command as specified. I created a batch script to run the commands here is an example.

    Unattend.cmd

    sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml /quit
    reg add HKLM\System\Setup /v CmdLine /t REG_SZ /d "cmd /c cscript //nologo C:\Windows\System32\Sysprep\EditUnattend.vbs" /f
    Shutdown /p /d p:2:4


    Mca
    • Proposed As Answer by DTE-ITGuy Wednesday, September 15, 2010 3:38 PM
    •  
  • Thursday, October 14, 2010 7:07 PM
     
     

    Hey Mike,

    I have been working with this script for 2 days and I am unable to have it run during the sysprep process.

    I have correctly added the line to the registry but the script will not run, meaning it never asks for the computer name input Do you have any ideas?

     I also had to change the variable _computername_replace_ because I kept getting an error stating the unattend file was invalid and sysprep would stop running and I would have to re-image the machine because I was unable to complete the setup.

  • Friday, October 15, 2010 3:55 PM
     
     
    I actually got the script to work. I had to log in under the administrator account. I am not sure why this would make a difference, but it worked perfectly. Thank you Mike for the script.
  • Wednesday, November 24, 2010 11:42 PM
     
     

    I've modified EditUnattend.vbs to use an XPath query to modify the ComputerName in Unattend.xml.  Basically you no longer have to modify Unattend.xml to add "_COMPUTERNAME_REPLACE_".

    =============================

    'a. prompt the user for the values you want to specify (such as ComputerName)
    'b. perform a string replace with those values in the C:\Windows\Panther\unattend.xml file (NOTE: not in C:\Sysprep.xml)
    'c. launch windeploy.exe to start the setup process

    ' ----- Begin sample: C:\Scripts\EditUnattend.vbs -----
    Option Explicit
    Dim answer, computerName, unattendFile, WshShell, fso, unattendFileObject, strContents, xmlDoc, n, oNodes

    unattendFile = "C:\Windows\Panther\unattend.xml"

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")

    Do While answer <> vbYes
       computerName = InputBox("Enter the desired Computer Name:", "Computer Name")
       answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & computerName, vbYesNo, "Verify Name")
    Loop

    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
    '''' Using XMLDOM to search Unattend.xml for replacement computername string.  Doing this allows this entire process to be fully automated
    '''' when added as a Task Sequence step to either ConfigMgr OSD or MDT

     Set xmlDoc = CreateObject("Microsoft.XMLDOM")
     xmlDoc.load unattendFile
     
     'Iterate through Unattend.xml searching for node ComputerName node/property
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each n in oNodes
      n.text = computername 'Replace the old computername in Unattend.xml with user-typed computername
      xmlDoc.save unattendFile 'Save modified Unattend.xml so that Specialize configuration pass can process the new computername after computer boots from Syspreped image
     Next

    ''''
    '''' End of XMLDOM search/replace
    ''''

    End If

    ' Launch setup (will use the modified unattend.xml)
    WScript.Sleep 5000
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True

  • Tuesday, December 07, 2010 3:12 PM
     
     

    Hi Everyone

    I managed to get the script to run and it does change C:\Windows\Panther\unattend.xml.

    However, when the machine comes up, it's still showing a random generated name.  I have ensured the account in the sysprep file is a member of the domain and is also a local admin.

    Anyone have any ideas why it's not working for me?

  • Wednesday, March 30, 2011 6:47 PM
     
     

    I've modified EditUnattend.vbs to do two things:

    1. Use XPath/XML to modify the computername, instead of using the Search/Replace method the original script did
    2. Modify Unattend.xml in two places (C:\Windows\Panther\Unattend.xml, C:\Windows\System32\Sysprep\Unattend.xml).  Probably not necessary, but did it just to make sure.

    =======================================

    'a. prompt the user for the values you want to specify (such as ComputerName)
    'b. perform a string replace with those values in the C:\Windows\Panther\unattend.xml file (NOTE: not in C:\Sysprep.xml)
    'c. launch windeploy.exe to start the setup process

    ' ----- Begin sample: C:\Scripts\EditUnattend.vbs -----
    Option Explicit
    Dim answer, computerName, unattendFile, unattendFile2, WshShell, fso, unattendFileObject, strContents, xmlDoc, xmlDoc2, n, j, oNodes, oNodes2

    unattendFile = "C:\Windows\Panther\unattend.xml"
    unattendFile2 = "C:\Windows\System32\Sysprep\unattend.xml"

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")

    Do While answer <> vbYes
       computerName = InputBox("Enter the desired Computer Name:", "Computer Name")
       answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & computerName, vbYesNo, "Verify Name")
    Loop

    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
     Set xmlDoc = CreateObject("Microsoft.XMLDOM")
     xmlDoc.load unattendFile
     
     'Iterate through Unattend.xml searching for node ComputerName node/property
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each n in oNodes
      n.text = computername 'Replace the old computername in Unattend.xml with user-typed computername
      xmlDoc.save unattendFile 'Save modified Unattend.xml so that Specialize configuration pass can process the new computername after computer boots from Syspreped image
     Next

    End If

    If fso.FileExists(unattendFile2) = False Then
       wscript.echo "ERROR: Could not find the unattend2 file"
    Else

     Set xmlDoc2 = CreateObject("Microsoft.XMLDOM")
     xmlDoc2.load unattendFile2
     
     'Iterate through Unattend.xml searching for node ComputerName node/property
     Set oNodes2 = xmlDoc2.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each j in oNodes2
      j.text = computername 'Replace the old computername in Unattend.xml with user-typed computername
      xmlDoc2.save unattendFile2 'Save modified Unattend.xml so that Specialize configuration pass can process the new computername after computer boots from Syspreped image
     Next

    End If

    ' Launch setup (will use the modified unattend.xml)
    WScript.Sleep 5000
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True

  • Monday, July 18, 2011 10:25 AM
     
     

    Let me see if I have this correct - FOUR YEARS after the original post in this thread was made, third party "workaround" scripting methods are STILL the only way to get a Windows 7 machine waking up from sysprep to prompt for a computername, BEFORE it tries to join the domain!?!?

    Why the Hell don't microsoft admit they stuffed up with Windows 7 sysprep compared to XP, and left out any way to prompt for a computer name in a sysprep pass that occurs BEFORE the UnattendJoinDomain pass?!?

    This is beyond belief. Here Microsoft is losing market share to Apple faster than you can say "i-anything" and Microsoft appear to be even more determined than ever to make it as difficult as possible for any non mega-corporation to automate deployment of their own main operating system!?

    I'm also confused by the vastly over complicated way Microsoft seemingly have three ways of trying to control OS configuration if you are using WDS/MDT solution to deploy Windows 7 that all seem to fight with each other for supremacy. It's also impossiblt to find any clear, plain english explanations of how these three technoligies interact with each other during the image deployment process, i.e. which one "Wins" in terms of configuration settings, further confusing what is a frustratinlgly over complicated process.

    For example, there is the option to specify a computer name and join domain option during the MDT wizard steps prior to starting an image deployment task sequence. However, if the image I want to deploy was sysprepped prior to capture, and therefore doesn't contain the <ComputerName>xxxxxxx<ComputerName> field, sysprep will prompt for a computername during the sysprep phase - won't that then overwrite the computer name I specified during the MDT Deployment wizard step?

    Why not just have unattend.xml as the ONLY way of specifying whether you want a machine to join a domain (like XP used to have) and leave it at that!?!?


  • Thursday, July 28, 2011 12:25 AM
     
      Has Code

    There's loads of people trying to get the setup process to prompt but clearly it's never going to work satisfactorily. Why not just write a FirstLogonCommand. I’ve written the very basic set of commands for my Win2008R2 SOE:

     

     

    @echo off
    
    for /f %%i in ('netsh interface ipv4 show interface^|findstr /i "local area"') do set /a localNIC=%%i
    
    echo Enter the new servers IP, name and domain info below
    
    echo.
    
    set /P IPaddr=[Enter a server IP address] 
    
    set /P netmask=[Enter a subnet mask] 
    
    set /P defgateway=[Enter a default gateway] 
    
    set /P dns1=[Enter a primary DNS server IP] 
    
    set /P dns2=[Enter a secondary DNS server IP] 
    
    
    
    netsh interface ipv4 set address name="%localNIC%" source=static address=%IPaddr% mask=%netmask% gateway=%defgateway%
    
    netsh interface ipv4 add dns "%localNIC%" %dns1% index=1 validate=no
    
    netsh interface ipv4 add dns "%localNIC%" %dns2% index=2 validate=no
    
    echo IP config added
    
    
    
    :renameadd
    
    set /P newname=[Enter the new computer name] 
    
    set /P dom=[Enter the Domain to join (shortname excluding .domain.com) e.g. prod] 
    
    set /P UN=[domain username for domain join (domain\username)] 
    
    rem set /P locadmin=[Local computer administrator username] 
    
    
    
    ping -n 1 %dom%.domain.com 1>null && if errorlevel 0 goto continue
    
    
    
    :exit
    
    echo Can't find domain controller. Exiting
    
    pause
    
    exit 0
    
    
    
    :continue
    
    echo.
    
    echo On successful completion the computer will automatically reboot
    
    netdom join %computername% /Domain:%dom%.domain.com /OU:ou=Servers,dc=%dom%,dc=domain,dc=com /UserD:%UN% /PasswordD:* && if 
    
    
    
    errorlevel 1 goto renameadd
    
    if %errorlevel% NEQ 0 echo "Problems with joining the domain. Retrying." && goto renameadd
    
    netdom renamecomputer %computername% /newname:%newname% /UserD:%UN% /PasswordD:* /usero:administrator /passwordo:tmplocal /force /REBoot:30
    
    
    

     

    I'm no self proclaimed script guru so I'm sure much more error checking and smarts can be added to this. It works fine for me. Note that I add the computer to the domain using the automatically generated name and then rename it. This is because once a computer is renamed it can't be added to a domain until a reboot has occurred although the reverse is not true.

    The only smarts I have in my script are:

    - Check which adapter is the 'Local Area Connection ##'. Will add the IP irrespective if it's called #2, #3 etc. Clearly this won't work well for multihomed/clustered nodes

    - Ensure's a DC can be contacted before an attempt to add to the domain is made.

    I stress that this is basic but it works just fine.

    Sheldon

  • Saturday, January 07, 2012 12:58 AM
     
      Has Code

    Here is a variation on some of the other contributions. WMI of the BIOS for serial number works. Using the XMLDOM to modify the xml. Using HTA instead of cmd /c wscript or vbscript. WARNING - If you play with this and you are not in setup, it will hose your system unless you reset hklm\system\setup\SystemSetupInProgress to 0

    reg add HKLM\System\Setup /v CmdLine /t REG_SZ /d "mshta C:\Windows\System32\Sysprep\EditUnattend.hta" /f

    <html>
    <head>
    <title>Computer Deployment</title>
    <HTA:APPLICATION 
         ID="objCompDeploy" 
         APPLICATIONNAME="Computer Deployment"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         maximizeButton="no"
         minimizeButton="no"
         sysMenu="no"
    >
    </head>
    <SCRIPT LANGUAGE="VBScript">
    
    Set WshShell = CreateObject("Wscript.Shell")
    
    Sub Window_onLoad
    window.resizeTo 450,400
    
    'turn off setup flag in registry so we can query wmi
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 0, "REG_DWORD"
    
    'query wmi for serial number
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)
    
       For Each objItem In colItems
          serialNumber = objItem.SerialNumber
       Next
    
    'turn setup flag back on
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 1, "REG_DWORD"
    
    'put the serial number that was retrieved in the textbox
    ComputerNameArea.Value = serialNumber
    
    End Sub 
    
    Sub modUnattend
    
    run_button.Disabled = True
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
    unattendFile = base & "\Panther\unattend.xml"
    
    
       computerName = ComputerNameArea.Value
       domainName = DomainNameArea.Value
       userName = UserNameArea.Value
       domainAdminPass = PasswordArea.Value
       OUName = OUNameArea.Value
    
     Set xmlDoc = CreateObject("Microsoft.XMLDOM")
     xmlDoc.load unattendFile
     
     'Iterate through Unattend.xml searching for nodes and properties to replace
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each n in oNodes
      n.text = computerName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Domain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Password")
     For each n in oNodes
      n.text = domainAdminPass
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Username")
     For each n in oNodes
      n.text = userName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/JoinDomain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/MachineObjectOU")
     For each n in oNodes
      n.text = OUName
      xmlDoc.save unattendFile
     Next
    
    'launch the continuation of setup in a hidden window and wait for return
    'if we dont wait, closing mshta, closes windeploy.exe
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
    idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
    End Sub
    
    Sub closeHTA
    window.close
    End Sub
    
    Sub commandLine
    WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
    End Sub
    
    </SCRIPT>
    <body>
    <table border="0">
    <tr>
    <td>Computer Name:</td>
    <td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"></td>
    </tr>
    <tr>
    <td>Domain Name:</td>
    <td><input type="text" name="DomainNameArea" size="30" value="domain.local"></td>
    </tr>
    <tr>
    <td>Container OU:</td>
    <td>
    <select size="1" name="OUNameArea">
        <option value="OU=someou,DC=domain,DC=local">Desktops</option>
        <option value="OU=someotherou,DC=domain,DC=local">Laptops</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>User Name:</td>
    <td><input type="text" name="UserNameArea" size="30"></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type="password" name="PasswordArea" size="30"></td>
    </tr>
    </table> 
    <p align="right">
    <input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
    <p align="center">
    Note: The following characters are invalid for use in the computer name: "  `~!@#$%^&<span onClick="commandLine">*</span>()=+[]{}\|;:'",<>/?.  "
    You will not recieve any warning regarding incorrectly supplied parameters during setup. If any of them are incorrect, setup completion
    may take a long time.
    </body>
    
    


  • Wednesday, March 21, 2012 10:16 AM
     
     

    Thanks Tsaysoft,

    After hours of troubleshooting, I finally managed to prompt for Computer name using mysysprep.

    Thanks Heaps.

  • Wednesday, March 21, 2012 3:52 PM
     
     

    Thanks Tsaysoft,

    After hours of troubleshooting, I finally managed to prompt for Computer name using mysysprep.

    Thanks Heaps.


    No need to use mysysprep if you follow the process above using the scripts fist published by Mike_EEC and modified by others to make it more user friendly to their liking or environment. It is very simple to use and very efficient. I've been using this script for a couple of years now with the original sysprep.exe in Windows and it has worked just fine for me. I have also gone ahead and put this script in an HTA format to have it perform additional functions for my environment.

    Mca


    • Edited by DTE-ITGuy Wednesday, March 21, 2012 3:53 PM correct wording
    •  
  • Wednesday, March 21, 2012 8:24 PM
     
     
    Mysysprep is the superior solution in every way -- something designed and intended to work specifically for this. There is far less of a window for error. No programming ability is needed, no registry modification is needed, and it adds loads of other features. I'd say it's a pretty severe case of "Old IT Guy" syndrome if you're doing it with Mike_EEC's solution still. 
  • Thursday, March 22, 2012 7:13 PM
     
     

    Anyone using havealoha's HTA file?  I like this as it uses the service tag.  I run my sysprep file, then run the registry file to put the HTA application in Setup/Scripts.  I reboot the PC, it prompts for domain, username and password, but never adds the computer to the domain, upon reboot it asks for Computer Name. I am pulling out my hair (which doesn't exist).  Do I need to edit anything in the HTA file?

    TIA - Justin

  • Wednesday, April 11, 2012 9:14 PM
     
     
    Late to the party but this worked and I am super happy.
  • Wednesday, April 11, 2012 9:14 PM
     
     
    My hat is off to you sir.  Years later, this with Mikes thing is like butter.
  • Wednesday, May 02, 2012 9:50 PM
     
     

    Sorry for my English,

    Would it be possible to get the Mac address or a serial number (BIOS or other) in the script of Mike_EEC

  • Wednesday, May 02, 2012 10:43 PM
     
     

    Sorry for my English,

    Would it be possible to get the Mac address or a serial number (BIOS or other) in the script of Mike_EEC

     

    Yes it is possible with a few additional lines of code. The script from "havealoha" is doing something similar. Here though it's only searching for the serial number. Finding the MAC address of the NIC would take a little more work - plenty of help available on MS Script center, MSDN and the rest of the internet.

    strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)

       For Each objItem In colItems
          serialNumber = objItem.SerialNumber
       Next


    Mca

  • Thursday, May 03, 2012 3:39 PM
     
     

    If insert your script, sysprep loading crash. The serial number is it detected at this location?

    Option Explicit
    Dim answer, computerName, unattendFile, WshShell, fso, unattendFileObject, objItem, strContents, strComputer, objWMIService, colItems, wbemFlagReturnImmediately, wbemFlagForwardOnly

    unattendFile = "C:\Windows\Panther\unattend.xml"

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")

    strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

       For Each objItem In colItems
          computerName = objItem.SerialNumber
       Next

    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
       'Read the unattend file in and replace apprpriate variables
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
       strContents = unattendFileObject.ReadAll
       strContents = Replace(strContents, "_COMPUTERNAME_REPLACE_", computerName)
       unattendFileObject.Close

       'Write the updated contents back to the unattend file
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
       unattendFileObject.Write(strContents)
       unattendFileObject.Close
    End If

    ' Launch setup (will use the modified unattend.xml)
    WScript.Sleep 5000
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True

  • Monday, May 14, 2012 7:13 PM
     
     

    Hello,

    I have tried each variation of Mike's Script.  I get prompted for the name, however when it finially boots up, it still has a random name.

  • Tuesday, May 15, 2012 3:27 PM
     
     

    Hello,

    I have tried each variation of Mike's Script.  I get prompted for the name, however when it finially boots up, it still has a random name.

    IT_BOB the scripts do work, maybe you're doing something wrong. You must use the same naming variable in your script as what's in your sysprep.xml (unattend.xml) file. i.e. "_COMPUTERNAME_REPLACE_" must be exactly the same in all places. Here is another version of the script I developed which does a little more than just write the computer name to the 'unattend.xml' file but it also allow you to input what OU you would like the computer to be placed in. It is not the prettiest but it works. In my case I had multiple AD sites with overlapping and none over lapping OU naming convention and thus needed to find a way to place the computers in their proper OU. YOu may modify it as you desire to meet your needs. I got the idea from http://markalexanderbain.suite101.com/how-to-create-dynamic-comboboxes-with-vbscript-a85065

    <!-- Start of Script -->
    <HTML>
      <HEAD>
        <HTA:Application
           ApplicationName = "Select Computer OU"
           Border = "Thin"
           Scroll ="No"
           SysMenu = "No"
         ></HTA:Application>
       
          <TITLE>Select Computer OU</TITLE>
          <H4>Department OU --- Location OU</H4>
          <Select id='sel_dept'></Select>
          <Select id='sel_ous'></Select>
         
          <SCRIPT Language="VBScript">
          Option Explicit


          Dim answer, ComputerName, unattendFile, objShell, fso, unattendFileObject, strContents
          Dim iTimer, ResetOk
          unattendFile = "C:\Windows\Panther\unattend.xml"

          Set objShell = CreateObject("wscript.shell")
          Set fso = CreateObject("Scripting.FileSystemObject")

         '###############################################################################
         '# Name: Window_OnLoad
         '# Purpose: Functions to execute at load time Loads First Two Subroutines
         '###############################################################################
         Sub Window_OnLoad
             Sel_Dept_Onchange()
             CompName_OnLoad
         End Sub
        
          '###############################################################################
          '# This subroutine loads and prompts for computer name entry + validates it
          '# then writes the input to the *.xml file on confirmation
          '###############################################################################
         
          Sub CompName_OnLoad
              Do While answer <> vbYes
                 ComputerName = UCase(InputBox("Enter the desired Computer Name:","Computer Name","Entry is not Case Sensitive"))
                                If ComputerName = "" Then
                                   MsgBox("You did not enter a Computer Name"), vbExclamation
                                Else
                                   answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & ComputerName, vbYesNo, "Verify Name")
                                End If
              Loop
                If fso.FileExists(unattendFile) = False Then
                MsgBox("ERROR: Could not find the unattend file"), vbCritical
                Else
                'Read the unattend file in and replace apprpriate variables
                Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
                strContents = unattendFileObject.ReadAll
                strContents = Replace(strContents, "_COMPUTERNAME_REPLACE_", ComputerName)
                unattendFileObject.Close
                'Write the updated contents back to the unattend file
                Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
                unattendFileObject.Write(strContents)
                unattendFileObject.Close
                End If
          End Sub

          '###############################################################################
          '# Next the code is needed to load the data - and, as always,
          '# it's better to split the code into subroutines so that it can be re-used as required.
          '# The first subroutine is used to add an option to the select box:
          '###############################################################################

          Sub add_option (select_id, value, text)
              dim opt : set opt = document.createelement("option")
              opt.value = value
              opt.text = text
              select_id.add opt
              set opt = Nothing
          End Sub
          '###############################################################################
          '# The subroutine populates the select box with the contents of an array
          '###############################################################################

          Sub load_combo (select_id, option_array)
              dim i: for i = 0 to ubound(option_array)
              add_option select_id, i, option_array(i)
              next
          End Sub

          '###############################################################################
          '# This subroutine clears the contents of the drop-down list box:
          '# Necessary for a clean content selection
          '###############################################################################

          Sub clear_combo (select_id)
              select_id.options.length = 0
          End Sub

          '###############################################################################
          '# With the subroutines in place an array is required
          '# - this is used to populate the first of the select boxes:
          '###############################################################################

          dim depmnts : depmnts = array ("General Users", "Engineering", "Some OU", "Manufacturing")

              load_combo sel_dept, depmnts
          '###############################################################################
          '# This will be used to display the selections in both arrays and write the data
          '# onClick of a button
          '###############################################################################
          Sub SelectValue()
              Dim objOption, LocationOU, DepartmentOU
              Dim strBlank

              For Each objOption in sel_ous.Options
                  If objOption.Selected Then
                     LocationOU = objOption.InnerText
                  End If
              Next

              For Each objOption in sel_dept
                  If objOption.Selected Then
                     DepartmentOU = objOption.InnerText
                  End If
              Next

          '###############################################################################
          '# Read the unattend file in and replace apprpriate variables
          '###############################################################################
              Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
                  strContents = unattendFileObject.ReadAll

              If DepartmentOU = "_Manufacturing" Then
                 strBlank = ""
                 strContents = Replace(strContents, "OU=_LOCATION_,", strBlank)
                 strContents = Replace(strContents, "_DEPARTMENT_", DepartmentOU)
                 unattendFileObject.Close
          '###############################################################################
          '# Write the updated contents back to the unattend file
          '###############################################################################
              Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
                  unattendFileObject.Write(strContents)
                  unattendFileObject.Close
              Else
                  strContents = Replace(strContents, "_DEPARTMENT_",  DepartmentOU)
                  strContents = Replace(strContents, "_LOCATION_", LocationOU)
                  unattendFileObject.Close
          '###############################################################################
          '# Write the updated contents back to the unattend file
          '###############################################################################
              Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
                  unattendFileObject.Write(strContents)
                  unattendFileObject.Close
              End If
          '###############################################################################
          '# Launch Windeploy to continue Setup and wait 3sec before next step
          '###############################################################################

              DataArea.InnerHTML = "Running ...."
              document.body.style.cursor = "wait"
              iTimer = window.setTimeout("hideWindow", 3000, "VBScript")
          End Sub

          '###############################################################################
          '# Hide HTA Script Window from view
          '# Script must remain running for windeploy process otherwise system reboots
          '###############################################################################
          Sub hideWindow
              Dim windeployFile
              windeployFile =  Chr(34) & "C:\Windows\System32\oobe\windeploy.exe" & Chr(34)

              window.moveTo -2000,-2000
              window.clearTimeout(iTimer)
              objShell.Run windeployFile, 0, True
                          
          '###############################################################################
          '# Close HTA script window
          '###############################################################################

              window.close
          End Sub
                         
          '###############################################################################
          '# The second selection box is loaded from this array,
          '# but the array will change according to the selection from the first combo-box
          '###############################################################################

             dim general_users_ou : general_users_ou = split ("Corporate,HR,Payroll,Accounting,IT," _
                 & "Sales,Marketing", ",")
             dim engineering_ou : engineering_ou = split ("R&D,Production,Manufacturing," _
                 & "Shipping", ",")
             dim some_ou : some_ou = split ("R&D,Manufacturing,Shipping", ",")

          '###############################################################################
          '# One final subroutine is required - this will fire whenever the user changes
          '# the selection in the first drop-down list box:
          '###############################################################################
          Sub sel_dept_onchange
              clear_combo sel_ous
              select case sel_dept.value
                  Case 0 'General Users
                       load_combo sel_ous, general_users_ou
                  Case 1 'Engineering
                       load_combo sel_ous, engineering_ou
                  Case 2 'Some OU
                       load_combo sel_ous, some_ou
                  Case 3 'Field
                       add_option sel_ous, 3, "Comupters"
              end select
          End Sub

         </SCRIPT>

      </HEAD>
    </HTML>

    <BODY>
    <BODY bgcolor="lightblue"></BODY>
    <BODY onLoad="Window_OnLoad"></BODY>
          <P>
          <INPUT ID="LocnBtn" CLASS="BUTTON" TYPE="BUTTON" VALUE="RUN SCRIPT" OnClick="SelectValue()"> <BR><BR>
          <SPAN ID = "DataArea"></SPAN>
          <hr>
              <p>Select the 'Department OU' container from the first list box</p>
              <p>Select the 'Division OU' container from the second list box</p>
              <p>Click the 'RUN SCRIPT' button when selection(s) have been made</p>
          </hr>
          <hr>
              <br>This script is design to be used for modifying the unattend.xml writing the computer account you typed in the Pop-Up Box to the unattend file and the OUs you select from the drop down list as well.</br>
              <br>If the computer account already exist in AD in another OU it will not be move from its current location to the one you've selected here.</br>
              <br>The system will join the domain leaving the computer account in the OU it currently resides.</br>
          </hr>
    </BODY>
    <!-- End of Script -->


    Mca

  • Tuesday, May 15, 2012 4:51 PM
     
     

    I have "_COMPUTERNAME_REPLACE_" in both sysprep.xml and unattend.xml.

    sysprep.xml

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="specialize">
            <component name="Microsoft-Windows-RemoteAssistance-Exe" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>
                 <RegisteredOwner>####</RegisteredOwner>
                 <RegisteredOrganization>####</RegisteredOrganization>
                 <TimeZone>Eastern Standard Time</TimeZone>
         </component>
        </settings>
    </unattend>

    unattend.xml

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <AutoLogon>
                    <LogonCount>1</LogonCount>
                    <Username>Administrator</Username>
                    <Enabled>true</Enabled>
                    <Password>*SENSITIVE*DATA*DELETED*</Password>
                </AutoLogon>
                <FirstLogonCommands>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>c:\windows\system32\sysprep\delunattend.cmd</CommandLine>
                        <Description>delete the unattend xml answer file</Description>
                        <Order>3</Order>
                        <RequiresUserInput>false</RequiresUserInput>
                    </SynchronousCommand>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>c:\windows\system32\slui.exe</CommandLine>
                        <Description>Activate Wndows Now</Description>
                        <Order>1</Order>
                        <RequiresUserInput>true</RequiresUserInput>
                    </SynchronousCommand>
                    <SynchronousCommand wcm:action="add">
                        <Order>2</Order>
                        <Description>Install Control Point on E6500</Description>
                        <CommandLine>C:\Windows\System32\sysprep\findmodel.cmd</CommandLine>
                        <RequiresUserInput>false</RequiresUserInput>
                    </SynchronousCommand>
                </FirstLogonCommands>
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                    <NetworkLocation>Work</NetworkLocation>
                    <ProtectYourPC>3</ProtectYourPC>
                </OOBE>
                <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
                <DoNotCleanTaskBar>false</DoNotCleanTaskBar>
                <ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>
                <RegisteredOrganization>####</RegisteredOrganization>
                <RegisteredOwner>####</RegisteredOwner>
                <ShowWindowsLive>false</ShowWindowsLive>
                <TimeZone>Eastern Standard Time</TimeZone>
            </component>

    I am in training so I will test what you just posted by the end of the week.  I need to remove the Domain part.  We have mutiple Domains and I am trying to make a standard template.

    Thanks,

    Bob

  • Tuesday, May 15, 2012 5:27 PM
     
     

    This is adressed primarily to Mike_EEC and DTE-ITGuy:

    I like your approach, but I've only had moderate success with Mike's procedure. That is to say I can get everything to work except the actual changing of the computer's name in the "unattend.xml", and, hence, the actual computer's name, after running the "EditUnattend.vbs" during an actual setup. Just running the script by itself on an administrative machine, the computer name in the file contents does change, but this was not true for the "unattend.xml" used in the actual imaged system, in my live test run.

    I'm wondering if there are certain details of the procedure that need to be clarified, for the sake of understanding, that may have been misinterpreted. Questions that come to mind are as follows: What is the significance of using two different file names in the process, other than preventing confusion between the two, and their locations; and is their some special significance to modifying only the "unattend.xml" file in the "Panther" folder, and locating it specifically in that folder? In my test, I used only one file, named "unattend.xml", and located it in the "System32\sysprep" folder, with the appropriate reference to the intended file in the SysPrep command-line execution. There was no "Sysprep.xml" file used in my procedure, just the one "unattend.xml".

    I'm feeling very confident that this system will work, but I think I just need to understand all the mechanics of the process before I can achieve complete success. If you could help me better understand the details of the process, I would be greatful.

  • Tuesday, May 15, 2012 7:20 PM
     
     
    OK, just unsuccessfully ran the update.  Can I email you my files?
  • Tuesday, May 15, 2012 11:41 PM
     
     

    IT_BOB: Here is what I did - Create a batch file to carryout the launch of sysprep and write the registry value (launchsysp.cmd)
    Content of script:

    sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml /quit

    reg add HKLM\System\Setup /v CmdLine /t REG_SZ /d "cmd /c cscript //nologo C:\Windows\System32\Sysprep\EditUnattend.vbs" /f  or 'EditUnattend.hta - script I provided above'

    Shutdown /p /d p:2:4

    There are three key pieces to making this work.

    1. Your sysprep.xml file contains this line: "<ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>"

    2. Your EditUnattend.vbs/EditUnattend.hta script also contains this exactly (copy and paste):"_COMPUTERNAME_REPLACE_"
    3. Make sure you Unattend.xml file gets written to C:\Windows\Panther\ during the setup process and not to some other drive

    You can check this and also see if it got updated after you've entered your computer name in your script and clicked OK by doing a Shift+F10 which brings up a command windows. CD to the Panther folder and check to see if the unattand.xml file is there. If it is type 'notepad unattend.xml' to open the file and check to see if the computer name got written to the file.


    Mca

  • Wednesday, May 16, 2012 5:10 AM
     
     

    DTE-ITGuy: I apologize for interrupting your conversation with IT_BOB, but I think we need a little clarification, still.

    It looks to me like there may be other people in this thread that aren't fully clear on the "key pieces" that make this work. I was hoping you might elaborate a little more on what those keys really are, from some of the perspectives of others in this thread, as well. It looks to me as if you are validating my comment about putting the "unattend.xml" file in exactly the "Windows\Panther" directory - (as opposed to the "System32\sysprep\Panther", just to be clear). This is good info...

    I think we are mostly all aware of the fact that the [variable name] in the "Sysprep.xml" and/or "unattend.xml" must be the same as the [variable name] used in the "EditUnattend.vbs/.hta" script, perhaps this did need some clarification, for some. But, I still think we need to "clear the air" about which file(s) need to be modified and which file(s) may not.

    If it's not necessary to change the [variable name] in the file not located in the "Panther" folder, the question becomes - does that file even need the <ComputerName> tag line, for example. Moreover, it would nice to just clarify if the two files need be exactly the same, before the "EditUnattend" script is run, and/or after.

    It seems apparent from the content of the script that the "unattend.xml" file needs to be already located in the "Panther" folder before the whole process begins, or an error condition will be thrown, in addition to the existence of a "Sysprep.xml" file in the root of "C:\" or the "System32\sysprep\" directory. I just hope those of us who are having problems are not getting stuck on this item due to glossing-over.

    I believe, in my own test, my "EditUnattend" script didn't change the "_COMPUTERNAME_REPLACE_" value in the "unattend.xml", so I'm worried there was some crazy rights issue going on when the script was run, though there shouldn't have been. If you have any experience with such a thing, it would be good to know if there is a resolution to avoid such a pitfall, as this derailed the whole process, for me.

    Again, I apologize for interrupting your conversation with IT_BOB, but for those of us on the outside looking in, a little clarification will go a long way toward resolving some of the issues that may have been experienced as a result of misunderstanding. (The "Shift+F10" to check the file content was a nice tidbit to add in, as I wouldn't have known this, before.)

    Thanks, it's greatly appreciated!

    • Edited by cmc.tech Friday, May 25, 2012 6:59 PM
    •  
  • Wednesday, May 16, 2012 11:42 AM
     
     
    My original unattend.xml did not have a field for for computername.   Should it have this as well? "<ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>"
  • Wednesday, May 16, 2012 3:03 PM
     
     Proposed

    DTE-ITGuy: I apologize for interrupting your conversation with IT_BOB, but I think we need a little clarification, still.

    It looks to me like there may be other people in this thread that aren't fully clear on the "key pieces" that make this work. I was hoping you might elaborate a little more on what those keys really are, from some of the perspectives of others in this thread, as well. It looks to me as if you are validating my comment about putting the "unattend.xml" file in exactly the "Panther" folder (in the "Windows" directory, as opposed to the "System32\sysprep\Panther" - just to be clear). This is good info...

    I think we are mostly all aware of the fact that the [variable name] in the "Sysprep.xml" and/or "unattend.xml" must be the same as the [variable name] used in the "EditUnattend.vbs/.hta" script, perhaps this did need some clarification, for some. But, I still think we need to "clear the air" about which file(s) need to be modified and which file(s) may not.

    If it's not necessary to change the [variable name] in the file not located in the "Panther" folder, the question becomes - does that file even need the <ComputerName> tag line, for example. Moreover, it would nice to just clarify if the two files need be exactly the same, before the "EditUnattend" script is run, and/or after.

    It seems apparent from the content of the script that the "unattend.xml" file needs to be already located in the "Panther" folder before the whole process begins, or an error condition will be thrown, in addition to the existence of a "Sysprep.xml" file in the root of "C:\" or the "System32\sysprep\" directory. I just hope those of us who are having problems are not getting stuck on this item due to glossing-over.

    I believe, in my own test, my "EditUnattend" script didn't change the "_COMPUTERNAME_REPLACE_" value in the "unattend.xml", so I'm worried there was some crazy rights issue going on when the script was run, though there shouldn't have been. If you have any experience with such a thing, it would be good to know if there is a resolution to avoid such a pitfall, as this derailed the whole process, for me.

    Again, I apologize for interrupting your conversation with IT_BOB, but for those of us on the outside looking in, a little clarification will go a long way toward resolving some of the issues that may have been experienced as a result of misunderstanding. (The "Shift+F10" to check the file content was a nice tidbit to add in, as I wouldn't have known this, before.)

    Thanks, it's greatly appreciated!


    cmc.tech:

    Thanks for your questions regarding this matter and let me to see if I can make this even clearer. When you run sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml it copies the sysprep.xml file to C:\Windows\Panter folder and renames it to unattend.xml. The sysprep.xml file is the file you need to make sure that the variable _COMPUTERNAME_REPLACE_ is in. This variable could exist in two places in you sysprep.xml file.
    The first would be the standard computer name change section and the second would be in the domain section if you enable AutoLogon of the administrator or some other local account once setup is completed.
    <settings pass="specialize">
      <ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>

    <AutoLogon>
      <Domain>_COMPUTERNAME_REPLACE_</Domain>

    To validate if this process is working open a command prompt window (make sure you do not have an unattend.xml file in the Panther folder) and navigate to C:\Windows\System32\Sysprep folder (You must be logon either with the local administrator account or running the command prompt with elevated privileges.) Run 'sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml /quit.' After the process is complete check the C:\Windows\Panther folder for the unattend.xml file. Now run your EditUnattend.vbs/xml file and enter a computer name and check the unattned.xml file again to see it the computer name got written to it. If it didn't then something is wrong with your script.

    Mca

    • Edited by DTE-ITGuy Wednesday, May 16, 2012 10:12 PM EditUnattend.vbs/xml
    • Proposed As Answer by cmc.tech Friday, May 25, 2012 6:02 PM
    •  
  • Wednesday, May 16, 2012 3:05 PM
     
     
    My original unattend.xml did not have a field for for computername.   Should it have this as well? "<ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>"
    Yes it should... The unattend.xml file gets created when you run sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml. You do not need to manually create the unattend.xml file...see my comment to cmc.tech

    Mca

  • Thursday, May 17, 2012 11:56 AM
     
     
    That may be my problem.  I have been using a unattend.xml file as well.  I will try again this afternoon.
  • Thursday, May 17, 2012 7:37 PM
     
     

    That worked, should add to the steps to remove all instances of unattend.xml.  I had two copies.  If I deleted just the one in Panther, the one from the sysprep directory copied it over.  Removing both was the solution....

  • Thursday, May 24, 2012 3:39 AM
     
     

    DTE-ITGuy:

    Thanks for your reply. Sorry for my delay in responding, as I was on vacation. Yes, I think you have made the picture much clearer. First, for whatever reason, I was unaware of the Sysprep.xml being copied to "unattend.xml" in the "Panther" folder. Some have sugessted that the [technician] is supposed to copy the "unattend.xml" to the two locations, [System32\sysprep] and [Windows\Panther], manually, before initiating the SysPrep process. Some have even suggested the third [System32\sysprep\Panther] location, as well; but, some only mention the [System32\sysprep] location; while some point out that it can be anywhere that you specify in the command line. The fact that SysPrep will make the "Panther" copy for you is helpful information.

    This response may actually hold the key to why my test didn't work: because I only attempted to change the "unattend.xml" file I had located in the [System32\sysprep] directory, not the [copied] file in the [Windows\Panther] directory, since the former was the only [known] copy. This also explains the naming convention to distinguish between the original file, named "Sysprep.xml", and the copied file, which automatically gets named "unattend.xml".

    It was, also, a nice little tidbit to add in about the AutoLogon <Domain> tag entry. My guess is that this may fix the problem we are having with the AutoLogon not working for us, perhaps because we weren't, previously, able to fill in the domain information for the local administrator account. Bonus!! If these things work out, "we'll be in Fat City".

    (I think you meant "EditUnattend.vbs/.hta".)

    I'm not at work right now, but when I get there, I will be running a new test, (as soon as possible), to see if these items work. Thanks for the info, once again. It is greatly appreciated! (We've been trying to "wrangle these horses" for a long time now.)

    Thanks, I really do appreciate it!


    • Edited by cmc.tech Sunday, June 24, 2012 7:58 PM
    •  
  • Friday, May 25, 2012 6:47 PM
     
     

    DTE-ITGuy, IT_BOB, Mike_EEC, et al:

    I just finished another round of tests, and so far it's a success. At this point, we're only having issues with making the AutoLogon work more than once, on the first go-round. (After sysprepping the same machine more than once, this no longer works, but I'll try to work around this.) We, also, had some problems with respect to Group Policy, but I believe further testing will allow us to remedy those issues.

    Other than that, we now can successfully name our machines and join the domain, without breaking the Trust Relationship, as we did in the past. This alone will save us a good deal of work and frustration, since the properly named machine now joins the domain "without a lot of rotating and gyrating".

    Mike_EEC's process does work. I had my doubts when I tried to modify the [process] slightly, but now, thanks to DTE-ITGuy, I understand the reasons why some of the details are stated as they are, and which ones are to be taken literally - which usually isn't a problem for me. I don't think I can stresss enough how valuable this system is to our deployment process.

    I will continue to monitor this thread just in case someone brings up any new tricks, or has any issues, related to this thread.

    Thanks, I really do appreciate it!

    • Edited by cmc.tech Friday, May 25, 2012 7:03 PM
    •  
  • Monday, May 28, 2012 3:31 PM
     
     

    Hi Mike, a couple of questions if you dont mind.

    1.  The sysprep.xml that I create do I make a copy of it and and rename it as unattend.xml and place it in c:\windows\pather?  I currently dont have an unattend.xml in c:\windows\pather...  (sorry if this sounds daft).

    2.  once the VB script runs and it renames the computer, will it be joined to the domain using the new name? 

    Many thanks in advance for your help.  Regards. 

  • Monday, May 28, 2012 10:59 PM
     
     

    THEFORCE:

    I'm replying to your post, not because I presume to know as much as Mike_EEC or DTE-ITGuy, but because I've found this thread quite useful. I'm not sure Mike_EEC is still subscribed to this thread, as he may have moved on to other issues/threads, but I am still subscribed to this thread, so I thought I might be able to help point you in the right direction...

    1. As DTE-ITGuy pointed out to me, (see some of the above posts), the "sysprep.exe" process creates a file named "unattend.xml" in the [C:\Windows\Panther] folder, for you. (This is, apparently, signified in the command line with the "/unattend:" switch.) Long story short, during the sysprep process the file will be copied there (Windows\Panther), so the script has to assume that it is there, because that one is, apparently, the actual file from which the deployment information is gleaned, during the deployment process. So, don't worry about the "unattend.xml" file, in the "Panther" folder - but you can check to see that it is there, if you want, after sysprep has run, by opening that folder, prior to running sysprep, and leaving it open until after the process has finished. This is because the command we're using doesn't shut the machine down, but I've found that sysprep locks you out of Windows Explorer, so you must have it already opened, beforehand, if you want to see the contents after sysprep has run. (Check the time-stamp after-process if it was already there before you started.)

    2. One of the primary goals of this methodology is to make the computer join the domain with it's final name already in place prior to any attempt to join the domain. As long as you follow Mike's and DTE's directions, the script will run prior to the Windows Deployment process; therefore, as long as you have a valid domain, and valid credentials, listed in your XML answer file, it should happily join the domain with the new computer name, which you specified through the script's dialog prior to the usual deployment process, when the deployment proceeds.

    It, also, should be noted that you can name your answer file anything you want or need, (i.e., Sysprep, SysPrep, Unattend, Answer1, DeptX, DomainY, etc.), as long as you specify it by path and filename in your "/unattend:" switch's filename data, (i.e., in a location that won't cause a conflict with the [C:\Windows\Panther\unattend.xml] that sysprep.exe creates).

    I apologize if this seems a little long-winded, but I find that the more detail you can describe, the clearer the understanding will be...

    Regards,

    cmc.tech

    • Edited by cmc.tech Tuesday, May 29, 2012 1:13 AM
    •  
  • Tuesday, May 29, 2012 9:04 PM
     
     

    THEFORCE:

    I'm replying to your post, not because I presume to know as much as Mike_EEC or DTE-ITGuy, but because I've found this thread quite useful. I'm not sure Mike_EEC is still subscribed to this thread, as he may have moved on to other issues/threads, but I am still subscribed to this thread, so I thought I might be able to help point you in the right direction...

    1. As DTE-ITGuy pointed out to me, (see some of the above posts), the "sysprep.exe" process creates a file named "unattend.xml" in the [C:\Windows\Panther] folder, for you. (This is, apparently, signified in the command line with the "/unattend:" switch.) Long story short, during the sysprep process the file will be copied there (Windows\Panther), so the script has to assume that it is there, because that one is, apparently, the actual file from which the deployment information is gleaned, during the deployment process. So, don't worry about the "unattend.xml" file, in the "Panther" folder - but you can check to see that it is there, if you want, after sysprep has run, by opening that folder, prior to running sysprep, and leaving it open until after the process has finished. This is because the command we're using doesn't shut the machine down, but I've found that sysprep locks you out of Windows Explorer, so you must have it already opened, beforehand, if you want to see the contents after sysprep has run. (Check the time-stamp after-process if it was already there before you started.)

    2. One of the primary goals of this methodology is to make the computer join the domain with it's final name already in place prior to any attempt to join the domain. As long as you follow Mike's and DTE's directions, the script will run prior to the Windows Deployment process; therefore, as long as you have a valid domain, and valid credentials, listed in your XML answer file, it should happily join the domain with the new computer name, which you specified through the script's dialog prior to the usual deployment process, when the deployment proceeds.

    It, also, should be noted that you can name your answer file anything you want or need, (i.e., Sysprep, SysPrep, Unattend, Answer1, DeptX, DomainY, etc.), as long as you specify it by path and filename in your "/unattend:" switch's filename data, (i.e., in a location that won't cause a conflict with the [C:\Windows\Panther\unattend.xml] that sysprep.exe creates).

    I apologize if this seems a little long-winded, but I find that the more detail you can describe, the clearer the understanding will be...

    Regards,

    cmc.tech

    cmc.tech Nicely put...happy to have helped.

    @THEF0RCE - Read all post here carefully the answer to your questions on how to make this work is here.


    Mca

  • Monday, June 04, 2012 4:07 PM
     
     

    Sorry to resurrect this thread but I'm trying to follow what I've read in it and I'm having a strange issue.

    I'm using the editunattend.vbs and it's prompting for computer name & password successfully; I enter the info and mini-setup says it needs to reboot. After mini-setup reboots the computer Windows still prompts for a computer name and when I look in ADUC I see the computer has joined with a random name.

    Any thoughts on that one?

  • Monday, June 04, 2012 6:16 PM
     
     

    Sorry to resurrect this thread but I'm trying to follow what I've read in it and I'm having a strange issue.

    I'm using the editunattend.vbs and it's prompting for computer name & password successfully; I enter the info and mini-setup says it needs to reboot. After mini-setup reboots the computer Windows still prompts for a computer name and when I look in ADUC I see the computer has joined with a random name.

    Any thoughts on that one?


    Please read all previous post and follow the direction exactly. Also read points I made to “CMC.TECH, IT_BOB” and all points they have made which they describe what they did or weren’t doing to get theirs working. Read, read and read. All the information to make it work is here.



    • Edited by DTE-ITGuy Monday, June 04, 2012 6:19 PM
    •  
  • Wednesday, June 13, 2012 2:01 PM
     
     

    THEFORCE:

    I'm replying to your post, not because I presume to know as much as Mike_EEC or DTE-ITGuy, but because I've found this thread quite useful. I'm not sure Mike_EEC is still subscribed to this thread, as he may have moved on to other issues/threads, but I am still subscribed to this thread, so I thought I might be able to help point you in the right direction...

    1. As DTE-ITGuy pointed out to me, (see some of the above posts), the "sysprep.exe" process creates a file named "unattend.xml" in the [C:\Windows\Panther] folder, for you. (This is, apparently, signified in the command line with the "/unattend:" switch.) Long story short, during the sysprep process the file will be copied there (Windows\Panther), so the script has to assume that it is there, because that one is, apparently, the actual file from which the deployment information is gleaned, during the deployment process. So, don't worry about the "unattend.xml" file, in the "Panther" folder - but you can check to see that it is there, if you want, after sysprep has run, by opening that folder, prior to running sysprep, and leaving it open until after the process has finished. This is because the command we're using doesn't shut the machine down, but I've found that sysprep locks you out of Windows Explorer, so you must have it already opened, beforehand, if you want to see the contents after sysprep has run. (Check the time-stamp after-process if it was already there before you started.)

    2. One of the primary goals of this methodology is to make the computer join the domain with it's final name already in place prior to any attempt to join the domain. As long as you follow Mike's and DTE's directions, the script will run prior to the Windows Deployment process; therefore, as long as you have a valid domain, and valid credentials, listed in your XML answer file, it should happily join the domain with the new computer name, which you specified through the script's dialog prior to the usual deployment process, when the deployment proceeds.

    It, also, should be noted that you can name your answer file anything you want or need, (i.e., Sysprep, SysPrep, Unattend, Answer1, DeptX, DomainY, etc.), as long as you specify it by path and filename in your "/unattend:" switch's filename data, (i.e., in a location that won't cause a conflict with the [C:\Windows\Panther\unattend.xml] that sysprep.exe creates).

    I apologize if this seems a little long-winded, but I find that the more detail you can describe, the clearer the understanding will be...

    Regards,

    cmc.tech

    Hi cmc.tech and DTE-ITGuy, appologies for the original post. I was too hasty to post to Mike, without realizing the many posts below that answered my question. However at the risk of sounding stupid again I have another question on the same matter.

    I have created the .vbs and and the sysprep.xml, and after syspreping the computer and rebooting, i'm promted for a computer name and its joined to the domain etc.. with is great. HOWEVER, when i take a image of that machine and add it to WDS, during the deployment of the image, I get a prompt that says type computer name, but this does nothing, as the computer is added using the %61Username%# format specified in WDS(so if the username used during the pxe phase is admin, then the computers will be admin1 admin2 etc..)

    Suggestion on here by DTE-ITEGuy is to prestage. I understand pre-staging, but thats not what I want to do. What I'm trying to acheive is exactly what mike describes with the .vbs and sysprep via wds, without needing to prestage. Is this not possible?

    if its not possible, does that mean all the guys on here that have said it works for them, are not using WDS?

  • Wednesday, June 13, 2012 3:26 PM
     
     Proposed

    What is actually happening here is that you have specified in WDS to 'Join a Domain' under I think the client Tab of the WDS properties, "Don't do this." Doing this overrides the functionality of the script you developed. The join domain functionality should be in your sysprep.xml/unattend.xml file which it sounds like you are already doing but I'll paste an example below anyway for reference.

    <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Identification>
        <Credentials>
            <Domain>MyDomain</Domain>
            <Password>MySup3rSecr3tPWd</Password>
            <Username>JoinADAcct</Username>
        </Credentials>
        <JoinDomain>my.domain.com</JoinDomain>
        <MachineObjectOU>OU=Computers,OU=IT,DC=my,DC=domain,DC=com</MachineObjectOU> "This is where my htm file would work if you have muti computer OU"
    </Identification>
    </component>


    Mca

    • Proposed As Answer by THEF0RCE Friday, June 15, 2012 2:50 PM
    •  
  • Friday, June 15, 2012 11:43 AM
     
     

    What is actually happening here is that you have specified in WDS to 'Join a Domain' under I think the client Tab of the WDS properties, "Don't do this." Doing this overrides the functionality of the script you developed. The join domain functionality should be in your sysprep.xml/unattend.xml file which it sounds like you are already doing but I'll paste an example below anyway for reference.

    <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Identification>
        <Credentials>
            <Domain>MyDomain</Domain>
            <Password>MySup3rSecr3tPWd</Password>
            <Username>JoinADAcct</Username>
        </Credentials>
        <JoinDomain>my.domain.com</JoinDomain>
        <MachineObjectOU>OU=Computers,OU=IT,DC=my,DC=domain,DC=com</MachineObjectOU> "This is where my htm file would work if you have muti computer OU"
    </Identification>
    </component>


    Mca

    A tick in a box, is the cause of all that pain.  Thank you very much,, the unattended install/renaming works perfectly. I have another tongue and cheek question though!

    your more then welcome to tell me to buzz off, i dont mind, I've got the fundementals of what I need the rest is just a nice to have.  Anyway.. back to the question

    I see the code you've written that allows a person to type the OU that they would like to place a computer in.  Is it possible to have alist of OU's in a drop down list?  could you paste the code on this forum?

  • Friday, June 15, 2012 3:45 PM
     
     
    your more then welcome to tell me to buzz off, i dont mind, I've got the fundementals of what I need the rest is just a nice to have.  Anyway.. back to the question

    I see the code you've written that allows a person to type the OU that they would like to place a computer in.  Is it possible to have alist of OU's in a drop down list?  could you paste the code on this forum?

    THEF0RCE:

    Questions are always welcome so feel free to ask.
    Anyway; my code isn't actually asking you to enter the OU name but instead select it from a list of predefined OUs which you've entered into it. So essentially it is doing exactly what you what you are looking for. This line " dim depmnts : depmnts = array ("General Users", "Engineering", "Some OU", "Manufacturing") " loads the first of two drop list boxes. This could be Departments you decide and the 2nd list box could have different Locations which would be covered by these lines:

         '###############################################################################
          '# The second selection box is loaded from this array,
          '# but the array will change according to the selection from the first combo-box
          '###############################################################################

             dim general_users_ou : general_users_ou = split ("Corporate,HR,Payroll,Accounting,IT," _
                 & "Sales,Marketing", ",")
             dim engineering_ou : engineering_ou = split ("R&D,Production,Manufacturing," _
                 & "Shipping", ",")
             dim some_ou : some_ou = split ("R&D,Manufacturing,Shipping", ",")

    This next line is also critical to make this work so modify it if you need to.

          '###############################################################################
          '# One final subroutine is required - this will fire whenever the user changes
          '# the selection in the first drop-down list box:
          '###############################################################################
          Sub sel_dept_onchange
              clear_combo sel_ous
              select case sel_dept.value
                  Case 0 'General Users
                       load_combo sel_ous, general_users_ou
                  Case 1 'Engineering
                       load_combo sel_ous, engineering_ou
                  Case 2 'Some OU
                       load_combo sel_ous, some_ou
                  Case 3 'Field
                       add_option sel_ous, 3, "Comupters"
              end select
          End Sub

    This information is then written back to the unattend.xml file withing the C:\Windows\Panther folder to this line:
        <JoinDomain>my.domain.com</JoinDomain>
        <MachineObjectOU>OU=_LOCATION_,OU=_DEPARTMENT_,DC=my,DC=domain,DC=com</MachineObjectOU> "This is where my htm file would work if you have muti computer OU"
    Or <MachineObjectOU>OU=_LOCATION_,OU=Computer,OU=_DEPARTMENT_,DC=my,DC=domain,DC=com</MachineObjectOU> 'it doesn't matter hown many OUs deep as logon as you specify it initially and remove what you don't using the script base on your selection. That is what I do...The _LOCATION_ and _DEPARTMENT_ would be replaced by your selection after you click the 'Run Script' button.

    Make sure you format the strings correctly otherwise it will not work. Using example above the domain name would be my.domain.com and the computer would be placed in the Location, Computers container under the IT OU of the domaim.

    These lines performs the writing:
          '###############################################################################
          '# Write the updated contents back to the unattend file
          '###############################################################################
              Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
                  unattendFileObject.Write(strContents)
                  unattendFileObject.Close
              Else
                  strContents = Replace(strContents, "Computers",  DepartmentOU)
                  strContents = Replace(strContents, "IT", LocationOU)
                  unattendFileObject.Close

    Copy my full script just as it is above and run it, entering anything for a computer name just to gat pass that.

    Hope this helps, good luck...



    • Edited by DTE-ITGuy Friday, June 15, 2012 4:03 PM
    •  
  • Friday, July 06, 2012 3:52 PM
     
     

    Hi I used the Mike approach for vista and it worked great for prompting for computername. Now in windows 7 I am trying to add prompt for OU in the vbs script. The script bombs out as soon as I do. If i take out the OU part it works again. Im not a vbs script guy so not sure what I am missing. Any guidance would be much appreciated. Script below:

    Option Explicit
    Dim answer, computerName, MachineObjectOU, unattendFile, WshShell, fso, unattendFileObject, strContents,

    unattendFile = "C:\Windows\Panther\unattend.xml"
     
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
     
    Do While answer <> vbYes
       computerName = InputBox("Enter the desired Computer Name:", "Computer Name")
       answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & computerName, vbYesNo, "Verify Name")
    loop
     
    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
       'Read the unattend file in and replace apprpriate variables
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
       strContents = unattendFileObject.ReadAll
       strContents = Replace(strContents, "_COMPUTERNAME_REPLACE_", computerName)
       unattendFileObject.Close
     
       'Write the updated contents back to the unattend file
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
       unattendFileObject.Write(strContents)
       unattendFileObject.Close

    Do While answer <> vbYes
       computerName = InputBox("Enter the desired MachineObjectOU:", "MachineObjectOU")
       answer = MsgBox("Is this correct?" & vbCrLf & "MachineObjectOU:" & MachineObjectOU, vbYesNo, "Verify Name")
    Loop

    If fso.FileExists(unattendFile) = False Then
       wscript.echo "ERROR: Could not find the unattend file"
    Else
       'Read the unattend file in and replace apprpriate variables
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
       strContents = unattendFileObject.ReadAll
       strContents = Replace(strContents, "_MachineObjectOU_REPLACE_", MachineObjectOU)
       unattendFileObject.Close

    'Write the updated contents back to the unattend file
       Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
       unattendFileObject.Write(strContents)
       unattendFileObject.Close

    End If
     
    ' Launch setup (will use the modified unattend.xml)
    WScript.Sleep 5000
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True


    • Edited by Sajkov Friday, July 06, 2012 3:53 PM
    •  
  • Monday, July 09, 2012 8:17 PM
     
     

    Hi guys im kinda new with this...but i read this and re read this and i understand whats going here and i thank Mike for his script

    so here is my dilema

    im able to run the script and name the machine however when starting up it joins the domain but the name doesnt stick

    i have the EditUnattend in my scripts folder, i ran the sysprep to my sysprep.xml below and ran the reg hack and rebooted, nothing name still is a random generated.

    However if i dont join to domain it gives me a name and it sticks in my answer file below i have eula and welcome screen turned off could that be the reason why?

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="specialize">
            <component name="Microsoft-Windows-RemoteAssistance-Exe" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <ComputerName>_COMPUTERNAME_REPLACE_</ComputerName>
                <RegisteredOwner>xxxxxxx</RegisteredOwner>
                <RegisteredOrganization>xxxxxxxx</RegisteredOrganization>
                <TimeZone>Pacific Standard Time</TimeZone>
            </component>
            <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Identification>
                    <Credentials>
                        <Domain>domain</Domain>
                        <Username>login</Username>
                        <Password>password</Password>
                    </Credentials>
                    <JoinDomain>domain</JoinDomain>
                </Identification>
            </component>
        </settings>
        <settings pass="oobeSystem">
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <ProtectYourPC>1</ProtectYourPC>
                    <SkipMachineOOBE>true</SkipMachineOOBE>
                    <SkipUserOOBE>true</SkipUserOOBE>
                    <NetworkLocation>Work</NetworkLocation>
                </OOBE>
            </component>
        </settings>
        <cpi:offlineImage cpi:source="catalog:e:/sources/install_windows 7 enterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>

  • Monday, August 13, 2012 8:42 PM
     
     

    the script is editing unattended.xml but nothing is changing in windows.

    mysysprep just says unknown error as soon as i try to launch it.

  • Wednesday, November 14, 2012 4:14 PM
     
     

    your more then welcome to tell me to buzz off, i dont mind, I've got the fundementals of what I need the rest is just a nice to have.  Anyway.. back to the question

    I see the code you've written that allows a person to type the OU that they would like to place a computer in.  Is it possible to have alist of OU's in a drop down list?  could you paste the code on this forum?

    THEF0RCE:

    Questions are always welcome so feel free to ask.
    Anyway; my code isn't actually asking you to enter the OU name but instead select it from a list of predefined OUs which you've entered into it. So essentially it is doing exactly what you what you are looking for. This line " dim depmnts : depmnts = array ("General Users", "Engineering", "Some OU", "Manufacturing") " loads the first of two drop list boxes. This could be Departments you decide and the 2nd list box could have different Locations which would be covered by these lines:

         '###############################################################################
          '# The second selection box is loaded from this array,
          '# but the array will change according to the selection from the first combo-box
          '###############################################################################

             dim general_users_ou : general_users_ou = split ("Corporate,HR,Payroll,Accounting,IT," _
                 & "Sales,Marketing", ",")
             dim engineering_ou : engineering_ou = split ("R&D,Production,Manufacturing," _
                 & "Shipping", ",")
             dim some_ou : some_ou = split ("R&D,Manufacturing,Shipping", ",")

    This next line is also critical to make this work so modify it if you need to.

          '###############################################################################
          '# One final subroutine is required - this will fire whenever the user changes
          '# the selection in the first drop-down list box:
          '###############################################################################
          Sub sel_dept_onchange
              clear_combo sel_ous
              select case sel_dept.value
                  Case 0 'General Users
                       load_combo sel_ous, general_users_ou
                  Case 1 'Engineering
                       load_combo sel_ous, engineering_ou
                  Case 2 'Some OU
                       load_combo sel_ous, some_ou
                  Case 3 'Field
                       add_option sel_ous, 3, "Comupters"
              end select
          End Sub

    This information is then written back to the unattend.xml file withing the C:\Windows\Panther folder to this line:
        <JoinDomain>my.domain.com</JoinDomain>
        <MachineObjectOU>OU=_LOCATION_,OU=_DEPARTMENT_,DC=my,DC=domain,DC=com</MachineObjectOU> "This is where my htm file would work if you have muti computer OU"
    Or <MachineObjectOU>OU=_LOCATION_,OU=Computer,OU=_DEPARTMENT_,DC=my,DC=domain,DC=com</MachineObjectOU> 'it doesn't matter hown many OUs deep as logon as you specify it initially and remove what you don't using the script base on your selection. That is what I do...The _LOCATION_ and _DEPARTMENT_ would be replaced by your selection after you click the 'Run Script' button.

    Make sure you format the strings correctly otherwise it will not work. Using example above the domain name would be my.domain.com and the computer would be placed in the Location, Computers container under the IT OU of the domaim.

    These lines performs the writing:
          '###############################################################################
          '# Write the updated contents back to the unattend file
          '###############################################################################
              Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
                  unattendFileObject.Write(strContents)
                  unattendFileObject.Close
              Else
                  strContents = Replace(strContents, "Computers",  DepartmentOU)
                  strContents = Replace(strContents, "IT", LocationOU)
                  unattendFileObject.Close

    Copy my full script just as it is above and run it, entering anything for a computer name just to gat pass that.

    Hope this helps, good luck...



    Appologies for bringing this up again.. I was working on this a couple of months ago, and things were too busy so I just went with MIKE_EEC script of renaming the computer, then manually moving the computer to the correct OU (as this worked for me), but now that I have a bit more time I want to get DTE_ITGUYS script working.

    I have amended the script and saved it as a hta.  When I run it it looks like everything has worked except it doesn't update the c:\windows\panther\sysprep.xml.  I have also built a windows machine and done the following

    1. Created a deploy.bat file which contains the following

    c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /unattend:C:\Windows\System32\Sysprep\Sysprep.xml /quit
    reg add HKLM\System\Setup /v CmdLine /t REG_SZ /d "cmd /c cscript //nologo C:\Windows\System32\Sysprep\unattend.hta" /f

    2.  Placed a unattend.hta file (customized DTE_ITGUY's script) c:\windows\system32\sysprep, which contains the following (Note:  If I double click on the 'unattend.hta' it says gives me the option to name my computer and select department and OU, so I don't think there is anything wrong syntax wise)

    <!-- Start of Script -->
     <HTML>
     <HEAD>
     <HTA:Application
     ApplicationName = "Select Computer OU"
     Border = "Thin"
     Scroll ="No"
     SysMenu = "No"
     ></HTA:Application>

     <TITLE>Select Computer OU</TITLE>
     <H4>Department OU --- Location OU</H4>
     <Select id='sel_dept'></Select>
     <Select id='sel_ous'></Select>

     <SCRIPT Language="VBScript">
     Option Explicit
     
     Dim answer, ComputerName, unattendFile, objShell, fso, unattendFileObject, strContents
     Dim iTimer, ResetOk
     unattendFile = "C:\Windows\Panther\unattend.xml"

     Set objShell = CreateObject("wscript.shell")
     Set fso = CreateObject("Scripting.FileSystemObject")

     '###############################################################################
     '# Name: Window_OnLoad
     '# Purpose: Functions to execute at load time Loads First Two Subroutines
     '###############################################################################
     Sub Window_OnLoad
     Sel_Dept_Onchange()
     CompName_OnLoad
     End Sub

     '###############################################################################
     '# This subroutine loads and prompts for computer name entry + validates it
     '# then writes the input to the *.xml file on confirmation
     '###############################################################################

     Sub CompName_OnLoad
     Do While answer <> vbYes
     ComputerName = UCase(InputBox("Enter the desired Computer Name:","Computer Name","Entry is not Case Sensitive"))
     If ComputerName = "" Then
     MsgBox("You did not enter a Computer Name"), vbExclamation
     Else
     answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & ComputerName, vbYesNo, "Verify Name")
     End If
     Loop
     If fso.FileExists(unattendFile) = False Then
     MsgBox("ERROR: Could not find the unattend file"), vbCritical
     Else
     'Read the unattend file in and replace apprpriate variables
     Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
     strContents = unattendFileObject.ReadAll
     strContents = Replace(strContents, "_NAME_", ComputerName)
     unattendFileObject.Close
     'Write the updated contents back to the unattend file
     Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
     unattendFileObject.Write(strContents)
     unattendFileObject.Close
     End If
     End Sub

     '###############################################################################
     '# Next the code is needed to load the data - and, as always,
     '# it's better to split the code into subroutines so that it can be re-used as required.
     '# The first subroutine is used to add an option to the select box:
     '###############################################################################

     Sub add_option (select_id, value, text)
     dim opt : set opt = document.createelement("option")
     opt.value = value
     opt.text = text
     select_id.add opt
     set opt = Nothing
     End Sub
     '###############################################################################
     '# The subroutine populates the select box with the contents of an array
     '###############################################################################

     Sub load_combo (select_id, option_array)
     dim i: for i = 0 to ubound(option_array)
     add_option select_id, i, option_array(i)
     next
     End Sub

     '###############################################################################
     '# This subroutine clears the contents of the drop-down list box:
     '# Necessary for a clean content selection
     '###############################################################################

     Sub clear_combo (select_id)
     select_id.options.length = 0
     End Sub

     '###############################################################################
     '# With the subroutines in place an array is required
     '# - this is used to populate the first of the select boxes:
     '###############################################################################

     dim depmnts : depmnts = array ("Admin", "Arts","Computers with Smartboards","DesignTech","FacultyPCs","Humanities","Inclusion","InfoTech","Leadership Team","Learning Support","LPS Adopters","Maths","Science","Sports","StuSupport","Test Lab","English")

     load_combo sel_dept, depmnts
     '###############################################################################
     '# This will be used to display the selections in both arrays and write the data
     '# onClick of a button
     '###############################################################################
     Sub SelectValue()
     Dim objOption, LocationOU, DepartmentOU
     Dim strBlank

     For Each objOption in sel_ous.Options
     If objOption.Selected Then
     LocationOU = objOption.InnerText
     End If
     Next

     For Each objOption in sel_dept
     If objOption.Selected Then
     DepartmentOU = objOption.InnerText
     End If
     Next

     '###############################################################################
     '# Read the unattend file in and replace apprpriate variables
     '###############################################################################
     Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
     strContents = unattendFileObject.ReadAll

     If DepartmentOU = "_Manufacturing" Then
     strBlank = ""
     strContents = Replace(strContents, "OU=_LOCATION_,", strBlank)
     strContents = Replace(strContents, "_DEPARTMENT_", DepartmentOU)
     unattendFileObject.Close
     
    '###############################################################################
     '# Write the updated contents back to the unattend file
     '###############################################################################
     Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
     unattendFileObject.Write(strContents)
     unattendFileObject.Close
     Else
     strContents = Replace(strContents, "_DEPARTMENT_", DepartmentOU)
     strContents = Replace(strContents, "_LOCATION_", LocationOU)
     unattendFileObject.Close
     
    '###############################################################################
     '# Write the updated contents back to the unattend file
     '###############################################################################
     Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
     unattendFileObject.Write(strContents)
     unattendFileObject.Close
     End If
     
    '###############################################################################
     '# Launch Windeploy to continue Setup and wait 3sec before next step
     '###############################################################################

     DataArea.InnerHTML = "Running ...."
     document.body.style.cursor = "wait"
     iTimer = window.setTimeout("hideWindow", 3000, "VBScript")
     End Sub

     '###############################################################################
     '# Hide HTA Script Window from view
     '# Script must remain running for windeploy process otherwise system reboots
     '###############################################################################
     Sub hideWindow
     Dim windeployFile
     windeployFile = Chr(34) & "C:\Windows\System32\oobe\windeploy.exe" & Chr(34)

     window.moveTo -2000,-2000
     window.clearTimeout(iTimer)
     objShell.Run windeployFile, 0, True

     '###############################################################################
     '# Close HTA script window
     '###############################################################################

     window.close
     End Sub

     '###############################################################################
     '# The second selection box is loaded from this array,
     '# but the array will change according to the selection from the first combo-box
     '###############################################################################

     dim admin_ou : admin_ou = split ("Admin", ",")
     dim arts_ou : arts_ou = split ("Arts", ",")
     dim pcsmart_ou : pcsmart_ou = split ("Computers with Smartboards", ",")
     dim design_ou : design_ou = split ("DesignTech", ",")
     dim faculty_ou : faculty_ou =  split ("FacultyPCs", ",")
     dim hum_ou : hum_ou =  split ("Humanities,IWB Macchines", ",")
     dim inclusion_ou : inclusion_ou =  split ("Inclusion", ",")
     dim infotech_ou : infotech_ou =  split ("InfoTech,Net1,Net2,Net3", ",")
     dim leadership_ou : leadership_ou =  split ("LeadershipTeam,IWB", ",")
     dim lsupport_ou : lsupport_ou =  split ("EAL,Learning Support 1 and 2,Learning Support 3", ",")
     dim adopters_ou : adopters_ou =  split ("PCs with Active Inspire,Pcs with Sartboard", ",")
     dim maths_ou : maths_ou =  split ("Maths", ",")
     dim science_ou : science_ou =  split ("Science,Lab3", ",")
     dim sports_ou : sports_ou =  split ("Sports,PE Office", ",")
     dim stusupport_ou : stusupport_ou =  split ("StuSupport", ",")
     dim testlab_ou : testlab_ou =  split ("Test Lab", ",")
     dim english_ou : english_ou =  split ("English", ",")

     '###############################################################################
     '# One final subroutine is required - this will fire whenever the user changes
     '# the selection in the first drop-down list box:
     '###############################################################################
     Sub sel_dept_onchange
     clear_combo sel_ous
     select case sel_dept.value
    Case 0 'Admin
     load_combo sel_ous, admin_ou
     Case 1 'Arts
     load_combo sel_ous, arts_ou
     Case 2 'Smart
     load_combo sel_ous, pcsmart_ou
     Case 3 'Design
     load_combo sel_ous, design_ou
     Case 4 'Faculty
     load_combo sel_ous, faculty_ou
     Case 5 'Humanities
     load_combo sel_ous, hum_ou
     Case 6 'Inclusion
     load_combo sel_ous, inclusion_ou
     Case 7 'Humanities
     load_combo sel_ous, infotech_ou
     Case 8 'Leadership
     load_combo sel_ous, leadership_ou
     Case 9 'Learning Support
     load_combo sel_ous, lsupport_ou
     Case 10 'LPS Adopters
     load_combo sel_ous, adopters_ou
     Case 11 'Maths
     load_combo sel_ous, maths_ou
     Case 12 'Science
     load_combo sel_ous, science_ou
     case 13 'Sports
     load_combo sel_ous, sports_ou
     Case 14 'Student support
     load_combo sel_ous, stusupport_ou
     case 15 'Test Lab
     load_combo sel_ous, testlab_ou
     Case 16 'English
     load_combo sel_ous, english_ou
     end select
     End Sub

     </SCRIPT>

     </HEAD>
     </HTML>

     <BODY>
     <BODY bgcolor="lightblue"></BODY>
     <BODY onLoad="Window_OnLoad"></BODY>
     <P>
     <INPUT ID="LocnBtn" CLASS="BUTTON" TYPE="BUTTON" VALUE="RUN SCRIPT" OnClick="SelectValue()"> <BR><BR>
     <SPAN ID = "DataArea"></SPAN>
     <hr>
     <p>Select the 'Department OU' container from the first list box</p>
     <p>Select the 'Division OU' container from the second list box</p>
     <p>Click the 'RUN SCRIPT' button when selection(s) have been made</p>
     </hr>
     <hr>
     <br>This script is design to be used for modifying the unattend.xml writing the computer account you typed in the Pop-Up Box to the unattend file and the OUs you select from the drop down list as well.</br>
     <br>If the computer account already exist in AD in another OU it will not be move from its current location to the one you've selected here.</br>
     <br>The system will join the domain leaving the computer account in the OU it currently resides.</br>
     </hr>
     </BODY>
     <!-- End of Script -->

    3.  I place my sysprep.xml in the folder C:\windows\system32\sysprep, which looks like the following

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">

    <settings pass="specialize">
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <ProductKey>xxxx-xxxxx-xxxxx-xxxxxx-xxxx</ProductKey>
                <ComputerName>_NAME_</ComputerName>
                <RegisteredOrganization>myschool</RegisteredOrganization>
                <RegisteredOwner>myschool</RegisteredOwner>
                <ShowWindowsLive>false</ShowWindowsLive>
                <TimeZone>GMT Standard Time</TimeZone>
            </component>
            <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Identification>
                    <Credentials>
                        <Domain>myschool.local</Domain>
                        <Username>admin</Username>
                        <Password>adminpassword</Password>
                    </Credentials>
                    <JoinDomain>myschool.local</JoinDomain>
      <MachineObjectOU>OU=_DEPARTMENT_,OU=COMPUTERS,DC=myschool,DC=local</MachineObjectOU>
                </Identification>
            </component>
        </settings>

        <settings pass="oobeSystem">
            <component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <InputLocale>en-GB</InputLocale>
                <SystemLocale>en-GB</SystemLocale>
                <UILanguage>en-US</UILanguage>
                <UILanguageFallback>en-GB</UILanguageFallback>
                <UserLocale>en-GB</UserLocale>
            </component>
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <NetworkLocation>Work</NetworkLocation>
                    <ProtectYourPC>1</ProtectYourPC>
                </OOBE>
                <UserAccounts>
                    <LocalAccounts>
                        <LocalAccount wcm:action="add">
                            <Password>
                                <Value>dwBlAGwAYwBvAG0AZQBQAGEAcwBzAHcAbwByAGQA</Value>
                                <PlainText>false</PlainText>
                            </Password>
                            <Description>Local User</Description>
                            <DisplayName>Teacher</DisplayName>
                            <Group>administrators</Group>
                            <Name>Teacher</Name>
                        </LocalAccount>
                    </LocalAccounts>
                </UserAccounts>
                <TimeZone>GMT Standard Time</TimeZone>
                <RegisteredOrganization>myschool</RegisteredOrganization>
                <RegisteredOwner>myschool</RegisteredOwner>
                <ShowWindowsLive>false</ShowWindowsLive>
            </component>
        </settings>

    <cpi:offlineImage cpi:source="catalog:c:/windows/system32/sysprep/install_windows 7 professional.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>

    4.  I finally run the deploy.bat from a cmd console (opened as an administrator)

    computer reboots, but does not load/run the unattend.hta.  Can you please help on what I'm doing wrong, or what else I need to do to get it working.  Many thanks.

  • Tuesday, February 19, 2013 5:37 PM
     
     

    Havealoha, Would you be willing to customize this script? This looks like the best fit for me. I would like to add a second password field and have it check if the passwords match before allowing you to continue.

    Also, can you explain how the HTA window timeout works? it appears to disappear after a little bit. (looks like the computer is going into some sort of power saving mode with a black screen, but when I click the windows then it comes back to the windows logo but no HTA Screen.


    Yeah Buddy!

  • Wednesday, March 06, 2013 4:51 PM
     
      Has Code

    @Jay.lambert

    Here it is with a password confirmation box....

    The timeout just pauses the script for a while after the deployment finishes but before closing the hta. It seemed that closing the hta just after the deployment finished caused things to fail on some occasions. The blank screen you describe is part op the hardware detection deployment process. When that app activates, the hta app goes to the background. If you use alt+tab, you can bring it back up.

    <html>
    <head>
    <title>Computer Deployment</title>
    <HTA:APPLICATION 
         ID="objCompDeploy" 
         APPLICATIONNAME="Computer Deployment"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         maximizeButton="no"
         minimizeButton="no"
         sysMenu="no"
    >
    </head>
    <SCRIPT LANGUAGE="VBScript">
    
    Set WshShell = CreateObject("Wscript.Shell")
    
    Sub Window_onLoad
    window.resizeTo 450,400
    
    'turn off setup flag in registry so we can query wmi
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 0, "REG_DWORD"
    
    'query wmi for serial number
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)
    
       For Each objItem In colItems
          serialNumber = objItem.SerialNumber
       Next
    
    'turn setup flag back on
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 1, "REG_DWORD"
    
    'put the serial number that was retrieved in the textbox
    ComputerNameArea.Value = serialNumber
    
    End Sub 
    
    Sub modUnattend
    
    run_button.Disabled = True
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
    unattendFile = base & "\Panther\unattend.xml"
    
    
       computerName = ComputerNameArea.Value
       domainName = DomainNameArea.Value
       userName = UserNameArea.Value
       domainAdminPass = PasswordArea.Value
       domainAdminPassConfirm = PasswordAreaConfirm.Value
       OUName = OUNameArea.Value
    
    if not domainAdminPass = domainAdminPassConfirm then
    msgbox("The passwords do not match.")
    run_button.Disabled = False
    exit sub
    end if
    
     Set xmlDoc = CreateObject("Microsoft.XMLDOM")
     xmlDoc.load unattendFile
     
     'Iterate through Unattend.xml searching for nodes and properties to replace
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each n in oNodes
      n.text = computerName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Domain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Password")
     For each n in oNodes
      n.text = domainAdminPass
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Username")
     For each n in oNodes
      n.text = userName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/JoinDomain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/MachineObjectOU")
     For each n in oNodes
      n.text = OUName
      xmlDoc.save unattendFile
     Next
    
    'launch the continuation of setup in a hidden window and wait for return
    'if we dont wait, closing mshta, closes windeploy.exe
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
    idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
    End Sub
    
    Sub closeHTA
    window.close
    End Sub
    
    Sub commandLine
    WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
    End Sub
    
    </SCRIPT>
    <body>
    <table border="0">
    <tr>
    <td>Computer Name:</td>
    <td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"></td>
    </tr>
    <tr>
    <td>Domain Name:</td>
    <td><input type="text" name="DomainNameArea" size="30" value="domain.local"></td>
    </tr>
    <tr>
    <td>Container OU:</td>
    <td>
    <select size="1" name="OUNameArea">
        <option value="OU=someou,DC=domain,DC=local">Desktops</option>
        <option value="OU=someotherou,DC=domain,DC=local">Laptops</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>User Name:</td>
    <td><input type="text" name="UserNameArea" size="30"></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type="password" name="PasswordArea" size="30"></td>
    </tr>
    <tr>
    <td>Confirm Password:</td>
    <td><input type="password" name="PasswordAreaConfirm" size="30"></td>
    </tr>
    </table> 
    <p align="right">
    <input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
    <p align="center">
    Note: The following characters are invalid for use in the computer name: "  `~!@#$%^&<span onClick="commandLine">*</span>()=+[]{}\|;:'",<>/?.  "
    You will not recieve any warning regarding incorrectly supplied parameters during setup. If any of them are incorrect, setup completion
    may take a long time.
    </body>

  • Wednesday, March 06, 2013 5:25 PM
     
      Has Code

    Here it is with some other modifications:

    Support using a computers.csv file to prevent imaging to specific computers matching a serial number and assign custom computer names based on serial number.

    Support growing the partition by specified amount or to extent.

    Support confirmation of password

    computers.csv example:

    computername,serialnumber

    invalid,serialnumber


    answer file requires specialized pass component xml:

    <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <ExtendOSPartition>

    <Extend></Extend>

    <Size></Size>

    </ExtendOSPartition>

    </component>


    The hta:

    <html>
    <head>
    <title>Computer Deployment</title>
    <HTA:APPLICATION 
         ID="objCompDeploy" 
         APPLICATIONNAME="Computer Deployment"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         maximizeButton="no"
         minimizeButton="no"
         sysMenu="no"
    >
    </head>
    <SCRIPT LANGUAGE="VBScript">
    
    Set WshShell = CreateObject("Wscript.Shell")
    
    Sub Window_onLoad
    window.resizeTo 450,400
    
    'turn off setup flag in registry so we can query wmi
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 0, "REG_DWORD"
    
    'query wmi for serial number
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
       Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                              wbemFlagReturnImmediately + wbemFlagForwardOnly)
    
       For Each objItem In colItems
          serialNumber = objItem.SerialNumber
       Next
    
    'turn setup flag back on
    WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 1, "REG_DWORD"
    
    base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
    Const FOR_READING = 1
    
    strFilename = base & "\System32\sysprep\computers.csv"
    'strFilename = "c:\windows\System32\sysprep\computers.csv"
    
    Set objDictionary = CreateObject("Scripting.Dictionary")
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'If text file exists, read list of serial numbers and corresponding computer names 
    If objFSO.FileExists(strFilename) Then
    Set objFile = objFSO.OpenTextFile(strFilename, FOR_READING)
    
    Do Until objFile.AtEndOfStream
    line=Split(objFile.ReadLine, ",")
        objDictionary.Add line(0), line(1)
    Loop
    
    objFile.Close
    
    'resume next or if there are duplicates, error
    On Error Resume Next
    colKeys = objDictionary.Keys
    For Each strKey in colKeys
        If objDictionary.Item(strKey) = serialNumber Then
                if strKey = "invalid" then
                msgbox "This computer is not licensed for deployment."
                window.close
                end if
            ComputerNameArea.value = Left(strKey,15)
        End If
    Next
    
    Else
      msgbox "File " & strFilename & " not found."
    End If
    
    
    'put the serial number that was retrieved in the textbox because it was not found in computers.csv
    if ComputerNameArea.Value = "" then
    ComputerNameArea.Value = Left("ORD3" & serialNumber,15)
    end if
    
    'read the date from the last time sysprep was run
    CloneTags = WshShell.RegRead("HKLM\System\Setup\CloneTag")
    For Each CloneTag In CloneTags
     lastSysprep = CloneTag
    Next
    
    sysprep.InnerHTML = lastSysprep
    
    End Sub 
    
    Sub modUnattend
    
    run_button.Disabled = True
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
    unattendFile = base & "\Panther\unattend.xml"
    
    
       computerName = ComputerNameArea.Value
       domainName = DomainNameArea.Value
       userName = UserNameArea.Value
       domainAdminPass = PasswordArea.Value
       domainAdminPassConfirm = PasswordAreaConfirm.Value
       OUName = OUNameArea.Value
       ExtendPartition = ExtendPartitionArea.Value
       ExtendPartitionSize = ExtendPartitionSizeArea.Value
       
    if not domainAdminPass = domainAdminPassConfirm then
    msgbox("The passwords do not match.")
    run_button.Disabled = False
    exit sub
    end if
    
     Set xmlDoc = CreateObject("Microsoft.XMLDOM")
     xmlDoc.load unattendFile
     
     'Iterate through Unattend.xml searching for nodes and properties to replace
     
    
     If ExtendPartition = "Extent" Then
     Set currNode = xmlDoc.documentElement.selectSingleNode("/unattend/settings/component/ExtendOSPartition")
     Set deleteSizeNode = xmlDoc.documentElement.selectSingleNode("/unattend/settings/component/ExtendOSPartition/Size")
     set oldChild = currNode.removeChild(deleteSizeNode)
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ExtendOSPartition/Extend")
     For each n in oNodes
      n.text = "true"
      xmlDoc.save unattendFile
     Next
     End If
    
     If ExtendPartition = "Megabytes" Then
     Set currNode = xmlDoc.documentElement.selectSingleNode("/unattend/settings/component/ExtendOSPartition")
     Set deleteExtendNode = xmlDoc.documentElement.selectSingleNode("/unattend/settings/component/ExtendOSPartition/Extend")
     set oldChild = currNode.removeChild(deleteExtendNode)
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ExtendOSPartition/Size")
     For each n in oNodes
      n.text = ExtendPartitionSize
      xmlDoc.save unattendFile
     Next
     End If
     
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
     For each n in oNodes
      n.text = computerName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Domain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Password")
     For each n in oNodes
      n.text = domainAdminPass
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Username")
     For each n in oNodes
      n.text = userName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/JoinDomain")
     For each n in oNodes
      n.text = domainName
      xmlDoc.save unattendFile
     Next
    
     Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/MachineObjectOU")
     For each n in oNodes
      n.text = OUName
      xmlDoc.save unattendFile
     Next
    
    'launch the continuation of setup in a hidden window and wait for return
    'if we dont wait, closing mshta, closes windeploy.exe
    WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
    'WshShell.Run "notepad.exe", 1, True
    idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
    End Sub
    
    Sub closeHTA
    window.close
    End Sub
    
    Sub commandLine
    WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
    End Sub
    
    </SCRIPT>
    <body>
    <table border="0">
    <tr>
    <td>Computer Name:</td>
    <td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value=""></td>
    </tr>
    <tr>
    <td>Extend drive partition to extent or by # Megabytes:</td>
    <td><select size="1" name="ExtendPartitionArea">
        <option value="Extent">Extent (use remaining space)</option>
        <option value="Megabytes">Megabytes (specified below)</option>
    </select>
    </tr>
    <tr>
    <td># Megabytes:<br>
    20480 is a safe number for most desktops</td>
    <td><input type="text" name="ExtendPartitionSizeArea" size="30" value="40960"></td>
    </tr>
    <tr>
    <td>Domain Name:</td>
    <td><input type="text" name="DomainNameArea" size="30" value="domain.local"></td>
    </tr>
    <tr>
    <td>Container OU:</td>
    <td>
    <select size="1" name="OUNameArea">
        <option value="OU=someou,DC=domain,DC=local">Desktops</option>
        <option value="OU=someotherou,DC=domain,DC=local">Laptops</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>User Name:</td>
    <td><input type="text" name="UserNameArea" size="30"></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type="password" name="PasswordArea" size="30"></td>
    </tr>
    <tr>
    <td>Confirm Password:</td>
    <td><input type="password" name="PasswordAreaConfirm" size="30"></td>
    </tr>
    </table> 
    <p align="right">
    <input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
    <p align="center">
    Note: The following characters are invalid for use in the computer name: "  `~!@#$%^&<span onClick="commandLine">*</span>()=+[]{}\|;:'",<>/?.  "
    You will not recieve any warning regarding incorrectly supplied parameters during setup. If any of them are incorrect, setup completion
    may take a long time.
    </body>

  • Thursday, March 07, 2013 9:37 PM
     
     
    Thanks!

    Yeah Buddy!

  • Thursday, March 07, 2013 9:42 PM
     
     

    For what it's worth. it appears that MySysprep 2 works with Windows 8. I have done a little testing an have had no problems.

    Note: For some reason when I build my images on a VM MySetup.exe never gets added to the \HKEY_LOCAL_MACHINE\SYSTEM\Setup\CmdLine

    I found that I can just add it manually if needed.

    Hope that helps someone.


    Yeah Buddy!