Jump to content

XP-like sysprep with win7


Recommended Posts

Only superficially; It seems an order of magnitude more involved and seems to depend on SCCM for a lot of stuff.

From what I've gleaned so far, the entire deployment procedure would need to be changed from the PXE server setup onward :/

I don't mind admitting that I find the whole thing quite daunting :unsure:

Edited by Cyker
Link to comment
Share on other sites


creating_a_windows_7_hard_disk_recovery_solution.pdf
In order to get WinRE to deploy using an answer file, you need to do some things that are not in that document.

;) Thx... (again, not there yet - steeel larnin'...)
Have you looked into MDT?
Um, yeah... thx for reminder. Edited by submix8c
Link to comment
Share on other sites

Well if you do what I've done above with that batch file and vbs file and answerfile then I'm happy to report that the machine WILL join the domain using the name you give it when it reboots after sysprep and it will all be done in 1 boot and you can even specify the OU to put it in as part of the answerfile as shown above.

I did forget to show the vbs though which is very simple and just replaces the OOBE call in the registry before sysprep restarts and then runs the OOBE call at the end (only downside is it leaves a console window floating throughout and I've LOVE someone to tell me how to ditch that but it's the least of my worries for a system that works so well like previous XP sysprepping!).

But I'm now BEGGING someone to tell me how I can use the copyprofile true line without breaking sysprep! What needs to be done to make it work?

I'm also begging to know where the pages are I was reading the other day that had people listing all these registry customisations they apply to the default user by mounting the default ntuser.dat and then running the customisations and then dismounting it - seems I could use that instead of the copyprofile to make sure default/new users get the tweaks.

So here's the vbs

Option Explicit
Dim answer, answer2, computerName, domainAdminPass, 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

'Do While answer2 <> vbYes
' domainAdminPass = InputBox("Enter the Domain Admin Password :", "Domain Admin Password")
' answer2 = MsgBox("Is this correct?" & vbCrLf & "Domain Admin Password: " & domainAdminPass, vbYesNo, "Verify Password")
'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, "Win7SP1Computer", computerName)
'strContents = Replace(strContents, "ReplaceMe2", domainAdminPass)
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

Link to comment
Share on other sites

Only superficially; It seems an order of magnitude more involved and seems to depend on SCCM for a lot of stuff.

From what I've gleaned so far, the entire deployment procedure would need to be changed from the PXE server setup onward :/

I don't mind admitting that I find the whole thing quite daunting :unsure:

Actually, SCCM relies on MDT for some things (if integration is enabled), but MDT itself is completely stand-alone. However, it's ok to find it daunting :). I'd still recommend using MDT to build your answer files and task sequences, and boot to the MDT boot images from a PXE server or off of a bootable USB key rather than do things manually.

Link to comment
Share on other sites

I'm not doing things manually, I'm making an image and imaging it rather than making an isntallation then copying it and reinstalling it everywhere WIM style with WDS. I've trawled around and hopefully the examples on the following links should be enough to get everyone modifying their default user profile witht he registry at setupcomplete time I think rather than firstruntime though maybe it doesn't matter much. I certainly can't afford to try the copyprofile true option for sysprep as this seemed to destroy by build :| Not that I know why of course - but pretty sure that was the only line I changed when my sysprep started failing

http://www.windows-noob.com/forums/index.php?/topic/3379-configure-default-user-profile-while-deploying-windows-7/

http://mockbox.net/windows-7/227-customise-windows-7-default-profile.html

Link to comment
Share on other sites

  • 1 month later...

@leozack

I had the same problem with copy profile, I had to manually delete some older profile information that was stuck in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList . Delete the profiles from that key that do not have a directory in %USERPROFILE% . Better yet, delete all profiles except for the administrative account that you want to copy the profile from.

To get the floating cmd prompt to go away, call an hta using mshta instead of cscript. Here is my example:


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>


Link to comment
Share on other sites

Nice script, but could you tell me where to place the script.

like to i have to add a line into untanded.xml?

i want wds to prompt me for entering a computernamer and a domain user so i can add the computer into the domain.

Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...