PXE booting doesn't work well in our environment and so we choose to boot from flash drive to configure a new pc. Computer name is typed in before imaging and then injected after imaging so you can boot, type the name, and leave. The computer then joins the domain, auto logs on, and then runs a runonce script that is defined in the unattend.xml file. You could probably adopt this to work with the initial deployment wizard as well even though it's probably more complicated than you need. It also assumes that you have some drives mapped to the UNC path containing the images and the ds management share where you have the unattend.xml file you want to inject.
Save the following code as "imageMenu.hta" and tell your console to run imagemenu.hta just like you would an exe file. If you have included hta support in your pxe boot image, it should start up right away. It supports both ghost and redploy images. New images must be added in two places, find them both.
There is also a command to run DISM to inject drivers from a folder that is named the same as the computer model. I highly recommend that process for Windows 7 over deploy anywhere for Windows 7 hardware independant imaging. Just fix the root path and make sure your driver store has all the raw inf driver files in it as it will search it recursively. PM me if you want to learn more about the full flash drive boot process which has several more options on it for XP, 7, and scripted isntallations from a Win7 source disk.
<HTML>
<HEAD>
<TITLE>Welcome to Microsoft Windows PE</TITLE>
<HTA:APPLICATION
ID="imageMenu"
WINDOWSTATE="maximize"
BORDER="none"
INNERBORDER="no"
SHOWINTASKBAR="no"
SCROLL="no"
APPLICATIONNAME="Windows PE Wizard"
NAVIGABLE="yes">
<SCRIPT LANGUAGE="VBScript">
sub addOption (path, title)
dim opt : set opt = document.createelement("option")
opt.value = path
opt.text = title
Image_cb.add opt
set opt = nothing
end sub
Sub CheckKey()
Dim TheKey
TheKey = window.event.keyCode
if TheKey = 13 then
BeginImaging
end if
End Sub
Function LookupImageOptions()
FOR i= 0 to Image_cb.length
Image_cb.remove 0
NEXT
'List of images also goes here. Ghost, Rdeploy, and Wim supported
'xml files for wim installation must be put in the "orignalDVD" folder in the images folder
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
SELECT CASE Level_cb.value
Case "District"
addOption "I:\Images\Win7x32\District\DM_12-22-2011\WIN7_DM_12_22_2011.img","District Master 12-22-2011"
addOption "I:\Images\Win7x32\District\PlainVanillaTest\PlainVanillaTest.gho","PlainVanillaTest"
addOption "PlainVanilla.xml","Plain Vanilla For Image Creation"
Case "HighSchool"
Case "MiddleSchool"
Case "Elementary"
END SELECT
END FUNCTION
FUNCTION BeginImaging()
IF Level_cb.value = "None" THEN
MsgBox("You must choose a Model")
Exit Function
END IF
IF Image_cb.value = "None" THEN
MsgBox("You must choose an Image")
Exit Function
END IF
IF ComputerName.value = "" then
MsgBox("You must enter the new computer's name")
Exit Function
END IF
SET WSHShell = CreateObject("WScript.Shell")
'cleans the hard drive to remove corrupt or vendor partitions then create's a c drive of the correct size.
WSHShell.Run "cmd /c copy /Y I:\automation\NewPCDiskPart.txt x:\NewPCDiskPart.txt",,True
rc = WSHShell.Run ("diskpart /s x:\NewPCDiskPart.txt",,True)
if rc <> 0 then
MsgBox ("diskpart failed to clean and partition the disk, reboot into PE and try again")
Exit Function
end if
extension = LCase(Right(Image_cb.value,3))
SELECT CASE extension
Case "gho" 'image is in ghost format
rc = WSHShell.Run ("X:\Progra~2\ghost\ghost32.exe -clone,mode=restore,src=" & Image_cb.value & ",dst=1 -sure -batch -assign=*",,True)
'check for ghost errors
if rc <> 0 then
Dim objFSO, strTextFile, strData, strLine, arrLines
CONST ForReading = 1
strTextFile = "x:\windows\system32\ghosterr.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll
arrLines = Split(strData,vbCrLf)
MsgBox("Ghost " & arrLines(1) & ", " & arrLines(2) & " " & arrLines(3))
MsgBox("Command Given: " & "X:\Progra~2\Ghost\ghost32.exe -clone,mode=restore,src=" & Image_cb.value & ",dst=1 -sure -batch -assign=*")
Exit Function
end if
'wait 10 seconds
WSHShell.Run "ping -n 10 127.0.0.1",,True
'check for C drive
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists("c:\windows") Then
MsgBox("C drive not accessable, scripts cannot run. Reboot to flash drive and run the inject Sysprep task." & rc)
Exit Function
end if
'copy unattend.xml
rc = WSHShell.Run ("cmd /c copy /y I:\automation\sysprepcfgs\Win7CommitteeSysprepDomainJoin.xml c:\windows\panther\unattend.xml" ,,True)
if rc <> 0 then
msgbox("Cannot copy unattend.xml: " & rc)
Exit Function
end if
'replace computer name inside unattend.xml
rc = WSHShell.Run ("X:\searchandreplace c:\windows\panther\unattend.xml <ComputerName>* <ComputerName>" & ComputerName.value,,True)
if rc <> 1 then
msgbox("computer name couldn't be injected into unattend.xml: " & rc)
Exit Function
end if
'inject drivers and reboot
rc = WSHShell.Run ("cscript I:\automation\driverinjection.vbs",,True)
if rc <> 0 then
msgbox("driver injection failed with error: " & rc)
Exit Function
end if
WSHShell.Run "shutdown -r -t 00",,True
'verify that computer name is found in unattend.xml
rc = WSHShell.Run("find /C " & ComputerName.value & " c:\windows\panther\unattend.xml",,True)
if rc <> 0 then
msgbox("The computer's name could not be read from unattend.xml. Reinject sysprep after rebooting to flash drive")
Exit Function
end if
Case "img" 'image is in Rdeploy format
rc = WSHShell.Run ("X:\Progra~2\Rdeploy\rdeployt.exe -noprompt -rescan -md -f" & Image_cb.value,,True)
'check for rdeploy errors
if rc <> 0 then
msgbox("Rdeploy failed with error: " & rc)
Exit Function
end if
'wait 10 seconds
WSHShell.Run "ping -n 10 127.0.0.1",,True
'check for C drive
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists("c:\windows") Then
MsgBox("C drive not accessable, scripts cannot run. Reboot to flash drive and run the inject Sysprep task." & rc)
Exit Function
end if
'copy unattend.xml
rc = WSHShell.Run ("cmd /c copy /y I:\automation\sysprepcfgs\Win7CommitteeSysprepDomainJoin.xml c:\windows\panther\unattend.xml" ,,True)
if rc <> 0 then
msgbox("Cannot copy unattend.xml: " & rc)
Exit Function
end if
'replace computer name inside unattend.xml
rc = WSHShell.Run ("X:\searchandreplace c:\windows\panther\unattend.xml <ComputerName>* <ComputerName>" & ComputerName.value,,True)
if rc <> 1 then
msgbox("computer name couldn't be injected into unattend.xml: " & rc)
Exit Function
end if
'inject drivers and reboot
rc = WSHShell.Run ("cscript I:\automation\driverinjection.vbs",,True)
if rc <> 0 then
msgbox("driver injection failed with error: " & rc)
Exit Function
end if
WSHShell.Run "shutdown -r -t 00",,True
'verify that computer name is found in unattend.xml
rc = WSHShell.Run("find /C " & ComputerName.value & " c:\windows\panther\unattend.xml",,True)
if rc <> 0 then
msgbox("The computer's name could not be read from unattend.xml. Reinject sysprep after rebooting to flash drive")
Exit Function
end if
Case "xml" 'image is in WIM format
'determine if WinPE is 32bit or 64bit
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_OperatingSystem",,48)
For Each objItem in colItems
OSbit = objItem.OSArchitecture
Next
If inStr(image_cb.value,"64") = 0 then 'if 64 is not found in the name of the xml file, this must be for a 32bit image
If OSbit <> "32-bit" Then 'if WinPE is not 32bit, error as this is a 32bit WIM image.
msgbox("You cannot use a 32bit wim image from WinPE 64bit. Change your flash drive's boot.wim file to be the 32bit version.")
Exit Function
End If
Else 'This is a 64bit Wim Image
If OSbit = "32-bit" Then 'if WinPE is 32bit, error as this is a 64bit WIM image.
msgbox("Not supported yet")
Exit Function
End If
End If
'copy the unattendxml file to temp location x:\
SET WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "cmd /c copy /Y I:\images\win7x32\district\OriginalDVD\" & image_cb.value & " x:\unattendD204.xml",,True
if rc <> 0 then
msgbox ("I:\images\win7x32\district\OriginalDVD\" & image_cb.value & " failed to copy")
Exit Function
end if
'replace the computer's name in unattend.xml on the X drive
rc = WSHShell.Run ("X:\searchandreplace x:\unattendD204.xml <ComputerName>* <ComputerName>" & ComputerName.value,,True)
if rc <> 1 then
msgbox ("failed to inject computer name: " & rc)
Exit Function
End If
'begin windows setup and use the customized xml file.
WSHSHELL.Run "I:\Images\Win7x32\District\OriginalDVD\setup.exe /unattend:X:\unattendD204.xml",,True
End Select
SET WSHShell = NOTHING
END FUNCTION
</script>
</HEAD>
<BODY BGCOLOR="black" Text="white" onload="ComputerName.focus()" onkeydown="CheckKey()">
<center>
<div style="position:absolute;left:300; top:200; width:400;">
<fieldset>
<legend>Windows 7 32bit Images</legend>
Computer Name: <input name="ComputerName" type="text" maxlength="15" style="width: 220px; height: 22px"><BR><BR>
<select name="Level_cb" style="width: 150px" onChange="LookupImageOptions">
<option value="District">District Images</option>
<option value="HighSchool">HighSchool Images</option>
<option value="MiddleSchool">MiddleSchool Images</option>
<option value="Elementary">Elementary Images</option>
</select>
<select name="Image_cb" size=1 style="width: 200px">
'Relist district images in this section. Do not list images for other levels.
'xml files for wim installation must be put in the "orignalDVD" folder in the images folder
'----------------------------------------------------------------------------
'----------------------------------------------------------------------------
<option value="I:\Images\Win7x32\District\DM_12-22-2011\WIN7_DM_12_22_2011.img">District Master 12-22-2011</option>
<option value="I:\Images\Win7x32\District\PlainVanillaTest\PlainVanillaTest.gho">Plain Vanilla Test</option>
<option value="PlainVanilla.xml">Plain Vanilla for Image Creation</option>
</select><BR><BR>
<input id=runbutton style="width: 1.2in" type="button" value="Begin Imaging" name="BeginImagingBtn" onClick="BeginImaging" tabindex="1">
<BUTTON ACCESSKEY="B" STYLE="font-face:Tahoma;font-size:13px;width: 1.2in;" onclick="self.close()"><U>B</U>ack</BUTTON>
</fieldset>
</div>