<DiskConfiguration>
section of your autounattend.xml. You can then use Windows System Image Manager (SIM) or tools like DISMTools to generate/test the full answer file and ensure validity.<DiskConfiguration>
<WillShowUI>OnError</WillShowUI>
<Disk wcm:action="add">
<DiskID>0</DiskID> <!-- Usually the main system disk -->
<WillWipeDisk>true</WillWipeDisk>
<!-- EFI System Partition -->
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>EFI</Type>
<Size>100</Size> <!-- Size in MB -->
</CreatePartition>
<!-- Microsoft Reserved Partition -->
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>MSR</Type>
<Size>16</Size>
</CreatePartition>
<!-- Windows Partition -->
<CreatePartition wcm:action="add">
<Order>3</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
<!-- Recovery Partition -->
<CreatePartition wcm:action="add">
<Order>4</Order>
<Type>Primary</Type>
<Size>1000</Size> <!-- Size in MB: 1GB (adjust as needed) -->
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<!-- Set the Windows partition properties -->
<ModifyPartition wcm:action="add">
<Order>3</Order>
<PartitionID>3</PartitionID>
<Format>NTFS</Format>
<Letter>C</Letter>
<Label>Windows</Label>
<Active>true</Active>
</ModifyPartition>
<!-- Set the Recovery partition properties -->
<ModifyPartition wcm:action="add">
<Order>4</Order>
<PartitionID>4</PartitionID>
<Format>NTFS</Format>
<Label>Recovery</Label>
<TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
</ModifyPartition>
</ModifyPartitions>
</Disk>
</DiskConfiguration>
DE94BBA4-06D1-4D40-A16A-BFD50179D6AC
marks the partition for WinRE/Recovery ("Windows Recovery Environment").<Extend>true</Extend>
directive fills available space except for reserved/recovery partitions.winre.wim
file and register it with reagentc /setreimage
. Windows Setup usually takes care of WinRE automatically, but custom builds may require manual touch-up.autounattend.xml
under the windowsPE
pass.To create a recovery partition as part of an unattended (autounattend.xml) installation for Windows 11, you'll want to use the DiskConfiguration and CreatePartitions components in your answer file. This instructs Windows Setup to prepare a custom disk layout—including a dedicated recovery partition.
Below is an example snippet you can adapt and place in the<DiskConfiguration>
section of your autounattend.xml. You can then use Windows System Image Manager (SIM) or tools like DISMTools to generate/test the full answer file and ensure validity.
Example: autounattend.xml Recovery Partition Script
Code:<DiskConfiguration> <WillShowUI>OnError</WillShowUI> <Disk wcm:action="add"> <DiskID>0</DiskID> <!-- Usually the main system disk --> <WillWipeDisk>true</WillWipeDisk> <!-- EFI System Partition --> <CreatePartitions> <CreatePartition wcm:action="add"> <Order>1</Order> <Type>EFI</Type> <Size>100</Size> <!-- Size in MB --> </CreatePartition> <!-- Microsoft Reserved Partition --> <CreatePartition wcm:action="add"> <Order>2</Order> <Type>MSR</Type> <Size>16</Size> </CreatePartition> <!-- Windows Partition --> <CreatePartition wcm:action="add"> <Order>3</Order> <Type>Primary</Type> <Extend>true</Extend> </CreatePartition> <!-- Recovery Partition --> <CreatePartition wcm:action="add"> <Order>4</Order> <Type>Primary</Type> <Size>1000</Size> <!-- Size in MB: 1GB (adjust as needed) --> </CreatePartition> </CreatePartitions> <ModifyPartitions> <!-- Set the Windows partition properties --> <ModifyPartition wcm:action="add"> <Order>3</Order> <PartitionID>3</PartitionID> <Format>NTFS</Format> <Letter>C</Letter> <Label>Windows</Label> <Active>true</Active> </ModifyPartition> <!-- Set the Recovery partition properties --> <ModifyPartition wcm:action="add"> <Order>4</Order> <PartitionID>4</PartitionID> <Format>NTFS</Format> <Label>Recovery</Label> <TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID> </ModifyPartition> </ModifyPartitions> </Disk> </DiskConfiguration>
Key Notes:
- The GUID
DE94BBA4-06D1-4D40-A16A-BFD50179D6AC
marks the partition for WinRE/Recovery ("Windows Recovery Environment").- The
<Extend>true</Extend>
directive fills available space except for reserved/recovery partitions.- You may need a later step (e.g., with a post-setup script) to copy the actual
winre.wim
file and register it withreagentc /setreimage
. Windows Setup usually takes care of WinRE automatically, but custom builds may require manual touch-up.- Integrate this block into your full
autounattend.xml
under thewindowsPE
pass.See Also:
If you need the rest of the answer file template, or a script to register WinRE after install, just ask!
- Automated tools like DISMTools can generate this disk layout via a guided wizard if you’re not comfortable editing XML manually.
C:\Windows\System32\Recovery\Winre.wim
).reagentc /setreimage /path C:\Recovery\WindowsRE
reagentc /enable
<FirstLogonCommands>
or <RunSynchronous>
in OOBE
or specialize
pass, like so:<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>cmd /c mkdir C:\Recovery\WindowsRE</CommandLine>
<Description>Create Recovery Folder</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<CommandLine>cmd /c copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim</CommandLine>
<Description>Copy WinRE</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>3</Order>
<CommandLine>cmd /c reagentc /setreimage /path C:\Recovery\WindowsRE</CommandLine>
<Description>Register WinRE</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>4</Order>
<CommandLine>cmd /c reagentc /enable</CommandLine>
<Description>Enable WinRE</Description>
</SynchronousCommand>
</FirstLogonCommands>
reagentc
configures all necessary values.md C:\Recovery\WindowsRE
copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim
reagentc /setreimage /path C:\Recovery\WindowsRE
reagentc /enable
SetupComplete.cmd
or as a synchronous command in the answer file post-install pass).<RunSynchronous>
example for the specialize
pass or want details for applying this on custom partition paths!To register the Windows Recovery Environment (WinRE) after Windows installation (for example, in an autounattend post-setup phase), you typically use a command (CMD) rather than a registry edit. The process is:
In your autounattend.xml, you can have this run automatically via
- Ensure winre.wim exists (usually at
C:\Windows\System32\Recovery\Winre.wim
).- Register the recovery image using:
Code:reagentc /setreimage /path C:\Recovery\WindowsRE reagentc /enable
<FirstLogonCommands>
or<RunSynchronous>
inOOBE
orspecialize
pass, like so:
Key Details:Code:<FirstLogonCommands> <SynchronousCommand wcm:action="add"> <Order>1</Order> <CommandLine>cmd /c mkdir C:\Recovery\WindowsRE</CommandLine> <Description>Create Recovery Folder</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>2</Order> <CommandLine>cmd /c copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim</CommandLine> <Description>Copy WinRE</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>3</Order> <CommandLine>cmd /c reagentc /setreimage /path C:\Recovery\WindowsRE</CommandLine> <Description>Register WinRE</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>4</Order> <CommandLine>cmd /c reagentc /enable</CommandLine> <Description>Enable WinRE</Description> </SynchronousCommand> </FirstLogonCommands>
If you want a pure CMD script (to run afterward, or by SetupComplete.cmd), here is a single snippet:
- No registry hack is required:
reagentc
configures all necessary values.- WinRE will be enabled for recovery operations if the partition and WIM exist.
Place this in a batch file (e.g.,Code:md C:\Recovery\WindowsRE copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim reagentc /setreimage /path C:\Recovery\WindowsRE reagentc /enable
SetupComplete.cmd
or as a synchronous command in the answer file post-install pass).
Let me know if you need the exact<RunSynchronous>
example for thespecialize
pass or want details for applying this on custom partition paths!
<FirstLogonCommands>
in your autounattend.xml
) or place the commands inside a batch script (SetupComplete.cmd
) to have everything happen automatically after Windows setup completes.<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>cmd /c mkdir C:\Recovery\WindowsRE</CommandLine>
<Description>Create Recovery Folder</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>2</Order>
<CommandLine>cmd /c copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim</CommandLine>
<Description>Copy WinRE Image</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>3</Order>
<CommandLine>cmd /c reagentc /setreimage /path C:\Recovery\WindowsRE</CommandLine>
<Description>Register WinRE</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>4</Order>
<CommandLine>cmd /c reagentc /enable</CommandLine>
<Description>Enable WinRE</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<Order>5</Order>
<CommandLine>wbadmin start backup -backupTarget:D: -allCritical -quiet</CommandLine>
<Description>Full System Backup</Description>
</SynchronousCommand>
</FirstLogonCommands>
D:
(make sure the drive exists and has space!)SetupComplete.cmd
C:\Windows\Setup\Scripts\SetupComplete.cmd
):[USER=35331]@echo[/USER] off
md C:\Recovery\WindowsRE
copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim
reagentc /setreimage /path C:\Recovery\WindowsRE
reagentc /enable
wbadmin start backup -backupTarget:D: -allCritical -quiet
.cmd
file, you can copy/paste them straight into a batch file to use with SetupComplete.cmd
or call from <FirstLogonCommands>
. Make sure your backup destination is valid before automated backup!<RunSynchronous>
block in the specialize
pass.Yes, that's correct! You can run both the WinRE registration script and the full system image backup script at first login (using<FirstLogonCommands>
in yourautounattend.xml
) or place the commands inside a batch script (SetupComplete.cmd
) to have everything happen automatically after Windows setup completes.
Example: Both Scripts in First Logon (autounattend.xml)
Code:<FirstLogonCommands> <SynchronousCommand wcm:action="add"> <Order>1</Order> <CommandLine>cmd /c mkdir C:\Recovery\WindowsRE</CommandLine> <Description>Create Recovery Folder</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>2</Order> <CommandLine>cmd /c copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim</CommandLine> <Description>Copy WinRE Image</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>3</Order> <CommandLine>cmd /c reagentc /setreimage /path C:\Recovery\WindowsRE</CommandLine> <Description>Register WinRE</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>4</Order> <CommandLine>cmd /c reagentc /enable</CommandLine> <Description>Enable WinRE</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>5</Order> <CommandLine>wbadmin start backup -backupTarget:D: -allCritical -quiet</CommandLine> <Description>Full System Backup</Description> </SynchronousCommand> </FirstLogonCommands>
- This will:
- Prepare and populate the recovery folder
- Register and enable WinRE
- Trigger a full system image backup to
D:
(make sure the drive exists and has space!)Alternative: Place Both Scripts in
If you use a batch file (e.g.,SetupComplete.cmd
C:\Windows\Setup\Scripts\SetupComplete.cmd
):
Code:[USER=35331]@echo[/USER] off md C:\Recovery\WindowsRE copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim reagentc /setreimage /path C:\Recovery\WindowsRE reagentc /enable wbadmin start backup -backupTarget:D: -allCritical -quiet
Either method works—it’s just a matter of which phase of unattended setup you prefer.
If you want these commands as a single.cmd
file, you can copy/paste them straight into a batch file to use withSetupComplete.cmd
or call from<FirstLogonCommands>
. Make sure your backup destination is valid before automated backup!
Let me know if you need these adjusted for a network drive, specific partition ID, or for the<RunSynchronous>
block in thespecialize
pass.
FirstLogonCommands
or SetupComplete.cmd
), here are the most common reasons and troubleshooting steps:wbadmin
and reagentc
) require elevated permissions or may not work at the very first logon if the system isn’t fully set up yet.SetupComplete.cmd
runs as SYSTEM and is generally best for automation, but certain drives or services may not be available immediately after OOBE.wbadmin
cannot find D:
or if it doesn’t have enough space, it will fail and may hang the script.winre.wim
isn't present, copy
or reagentc
will error out.call
or start
for certain steps.[USER=35331]@echo[/USER] off
set LOGFILE=C:\setup_log.txt
echo Starting Recovery and Backup > %LOGFILE%
echo Creating recovery folder... >> %LOGFILE%
md C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
echo Copying winre.wim... >> %LOGFILE%
copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim >> %LOGFILE% 2>&1
echo Setting WinRE image... >> %LOGFILE%
reagentc /setreimage /path C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
echo Enabling WinRE... >> %LOGFILE%
reagentc /enable >> %LOGFILE% 2>&1
echo Starting WBAdmin backup... >> %LOGFILE%
wbadmin start backup -backupTarget:D: -allCritical -quiet >> %LOGFILE% 2>&1
echo Done! >> %LOGFILE%
C:\setup_log.txt
, which you can check after the install for errors.wbadmin
can fail if run from OOBE or very early first logon, especially if Shadow Copy services are not fully functional yet, or the target disk is not writable.net use Z: \\server\backupshare /user:username password
wbadmin start backup -backupTarget:Z: -allCritical -quiet
winre.wim
and make sure your backup target (D:
or network share) exists and is writeable.If the script is stopping or failing when run during Windows Setup (viaFirstLogonCommands
orSetupComplete.cmd
), here are the most common reasons and troubleshooting steps:
1. Permissions & Timing
- Some commands (especially
wbadmin
andreagentc
) require elevated permissions or may not work at the very first logon if the system isn’t fully set up yet.SetupComplete.cmd
runs as SYSTEM and is generally best for automation, but certain drives or services may not be available immediately after OOBE.2. Common Script Issues
- Target drive (D
is missing or empty: If
wbadmin
cannot findD:
or if it doesn’t have enough space, it will fail and may hang the script.- WinRE image missing or in use: If
winre.wim
isn't present,copy
orreagentc
will error out.- Syntax problems: Some commands need full paths, and you may need to use
call
orstart
for certain steps.3. Logging for Troubleshooting
- Add logging to your batch file to check exactly where it fails:
Code:[USER=35331]@echo[/USER] off set LOGFILE=C:\setup_log.txt echo Starting Recovery and Backup > %LOGFILE% echo Creating recovery folder... >> %LOGFILE% md C:\Recovery\WindowsRE >> %LOGFILE% 2>&1 echo Copying winre.wim... >> %LOGFILE% copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim >> %LOGFILE% 2>&1 echo Setting WinRE image... >> %LOGFILE% reagentc /setreimage /path C:\Recovery\WindowsRE >> %LOGFILE% 2>&1 echo Enabling WinRE... >> %LOGFILE% reagentc /enable >> %LOGFILE% 2>&1 echo Starting WBAdmin backup... >> %LOGFILE% wbadmin start backup -backupTarget:D: -allCritical -quiet >> %LOGFILE% 2>&1 echo Done! >> %LOGFILE%
- This will create
C:\setup_log.txt
, which you can check after the install for errors.4. Running Interactive Tools Like WBADMIN
wbadmin
can fail if run from OOBE or very early first logon, especially if Shadow Copy services are not fully functional yet, or the target disk is not writable.Alternatives:
- Test running the script manually after setup completes (as admin) to see if it runs without issues.
- Delay backup until setup is 100% complete, e.g., via Task Scheduler with a delay.
Network or Removable Storage?
- If targeting a network share, map it first:
Code:net use Z: \\server\backupshare /user:username password wbadmin start backup -backupTarget:Z: -allCritical -quiet
5. SetupComplete.cmd Specifics
- Do not require user interaction. If any scripted command stops and waits for a prompt, the entire setup hangs.
- No GUI/output is shown.
6. Testing and Isolation
- Try running each line individually in a command prompt after the OS is set up.
- Check paths for
winre.wim
and make sure your backup target (D:
or network share) exists and is writeable.Recommendations:
In summary:
- Post your log file or error message here for precise troubleshooting.
- If you’re working from a specific deployment, let me know which Windows version and what your drive layout looks like.
Add logging, isolate which command fails, check the state of all needed files/folders/targets, and confirm all paths. Post any error output for help on that exact step!
C:\setup_log.txt
) so you know exactly which command fails.SetupComplete.cmd
or as a batch file called by your unattend XML:[USER=35331]@echo[/USER] off
set LOGFILE=C:\setup_log.txt
echo %DATE% %TIME% - Starting Recovery and Backup > %LOGFILE%
echo Creating recovery folder... >> %LOGFILE%
md C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
echo Copying winre.wim... >> %LOGFILE%
copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim >> %LOGFILE% 2>&1
echo Registering WinRE image... >> %LOGFILE%
reagentc /setreimage /path C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
echo Enabling WinRE... >> %LOGFILE%
reagentc /enable >> %LOGFILE% 2>&1
echo Starting wbadmin backup... >> %LOGFILE%
wbadmin start backup -backupTarget:D: -allCritical -quiet >> %LOGFILE% 2>&1
echo %DATE% %TIME% - Script Complete >> %LOGFILE%
copy
, reagentc
, or wbadmin
is failing. You’ll know what to fix.C:\Windows\Setup\Scripts\SetupComplete.cmd
FirstLogonCommands
or a scheduled task after first boot.C:\setup_log.txt
, and read the last lines—the error will be clear.Yes, you should combine the logging version of the script with your existing recovery and backup commands, especially for troubleshooting during Windows unattended setup. This approach gives you a clear, step-by-step log (C:\setup_log.txt
) so you know exactly which command fails.
Here’s How You Can Combine Everything
Place the following in yourSetupComplete.cmd
or as a batch file called by your unattend XML:
Code:[USER=35331]@echo[/USER] off set LOGFILE=C:\setup_log.txt echo %DATE% %TIME% - Starting Recovery and Backup > %LOGFILE% echo Creating recovery folder... >> %LOGFILE% md C:\Recovery\WindowsRE >> %LOGFILE% 2>&1 echo Copying winre.wim... >> %LOGFILE% copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim >> %LOGFILE% 2>&1 echo Registering WinRE image... >> %LOGFILE% reagentc /setreimage /path C:\Recovery\WindowsRE >> %LOGFILE% 2>&1 echo Enabling WinRE... >> %LOGFILE% reagentc /enable >> %LOGFILE% 2>&1 echo Starting wbadmin backup... >> %LOGFILE% wbadmin start backup -backupTarget:D: -allCritical -quiet >> %LOGFILE% 2>&1 echo %DATE% %TIME% - Script Complete >> %LOGFILE%
Why This Is Smart
- Single script = simpler troubleshooting and fewer moving parts.
- **Log file*** shows you if—for example—
copy
,reagentc
, orwbadmin
is failing. You’ll know what to fix.- You can tweak, comment out, or re-order steps for your needs.
How to use:
- Place in
C:\Windows\Setup\Scripts\SetupComplete.cmd
- Or schedule/run the script via the
FirstLogonCommands
or a scheduled task after first boot.If You Hit An Error:
- Boot into Windows, open
C:\setup_log.txt
, and read the last lines—the error will be clear.- Post that error here if you need tailored help!
In summary: Yes, run the logging version as your “master” script for both WinRE setup and backup. This makes deployment troubleshooting vastly easier.
C:\setup_log.txt
.07/01/2024 13:41:12 - Starting Recovery and Backup
Creating recovery folder...
Copying winre.wim...
Registering WinRE image...
Enabling WinRE...
Starting wbadmin backup...
07/01/2024 13:41:28 - Script Complete
C:\setup_log.txt
will be missing or incomplete.SetupComplete.cmd
or your unattend file.C:\setup_log.txt
. If found, open it and paste the contents here for analysis.SetupComplete.cmd
is definitely located at C:\Windows\Setup\Scripts\SetupComplete.cmd
.C:\setup_log.txt
output with error messages on Microsoft forums or tech blogs. It will look much like standard Windows command prompt batch script text logs.I'm unable to provide a direct screenshot since I can't run Windows setup or scripts myself; however, I can help you analyze what should happen and what your log/output should look like.
What to expect when using the script:
If it DOESN’T work:
- After setup and first login, you should find
C:\setup_log.txt
.- Its lines would look similar to this:
Code:07/01/2024 13:41:12 - Starting Recovery and Backup Creating recovery folder... Copying winre.wim... Registering WinRE image... Enabling WinRE... Starting wbadmin backup... 07/01/2024 13:41:28 - Script Complete
- If an error occurs at any step, you’d see an error message after the relevant line (such as “The system cannot find the file specified,” or “Access is denied”).
What you should do now:
C:\setup_log.txt
will be missing or incomplete.- The step that fails will have an error message after its line.
- If no log is present, the script wasn’t run or failed to execute at all—typically due to a path error or a problem with the script’s entry in
SetupComplete.cmd
or your unattend file.
If you’ve uploaded a log or related file, let me know and I can locate/analyze it for you for next troubleshooting steps.
- Check for
C:\setup_log.txt
. If found, open it and paste the contents here for analysis.- If the log isn’t there:
- Check that your
SetupComplete.cmd
is definitely located atC:\Windows\Setup\Scripts\SetupComplete.cmd
.- Make sure there are no syntax errors or encoding issues (it must use Windows line endings and plain ASCII/UTF-8 text, not rich text or Word formatting).
- Ensure the script has execute permissions and isn’t blocked (“Unblock” it if you copied from another PC).
If you want visuals:
You can search for screenshots ofC:\setup_log.txt
output with error messages on Microsoft forums or tech blogs. It will look much like standard Windows command prompt batch script text logs.
If you attach or copy the actual log/output (or the error you see), I can give you step-by-step targeted help!
wbadmin
, so this script will only handle enabling WinRE (Windows Recovery Environment) and making a backup copy of user profiles (not the entire system image).[USER=35331]@echo[/USER] off
set LOGFILE=C:\setup_log.txt
echo %DATE% %TIME% - Starting Recovery and Data Backup > %LOGFILE%
:: Create recovery folder
echo Creating recovery folder... >> %LOGFILE%
md C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
:: Copy winre.wim if available
echo Copying winre.wim... >> %LOGFILE%
if exist C:\Windows\System32\Recovery\Winre.wim (
copy C:\Windows\System32\Recovery\Winre.wim C:\Recovery\WindowsRE\Winre.wim >> %LOGFILE% 2>&1
) else (
echo winre.wim not found, skipping copy >> %LOGFILE%
)
:: Register and enable WinRE
echo Registering WinRE image... >> %LOGFILE%
reagentc /setreimage /path C:\Recovery\WindowsRE >> %LOGFILE% 2>&1
echo Enabling WinRE... >> %LOGFILE%
reagentc /enable >> %LOGFILE% 2>&1
:: Backup user profiles to D: (change D: to your backup drive)
echo Backing up user profiles... >> %LOGFILE%
if exist D:\ (
xcopy /E /I /H /C /Y C:\Users D:\UserBackup >> %LOGFILE% 2>&1
echo Profiles backed up to D:\UserBackup >> %LOGFILE%
) else (
echo Backup drive D: not found, skipping backup >> %LOGFILE%
)
echo %DATE% %TIME% - Script Complete >> %LOGFILE%
C:\Windows\Setup\Scripts\SetupComplete.cmd
D:\UserBackup
. Change D:
to any external or second internal drive with enough space.D:
drive, update to another drive letter, network share, or USB drive.C:\setup_log.txt
for errors and results.reagentc
commands are included to ensure the recovery environment is registered and enabled.xcopy
is used for user profile data backup, which is the closest built-in equivalent to a full backup for Home editions."C:\Program Files\Macrium\Reflect\Reflect.exe" -e -w -full -img D:\Backup\WinHomeBackup.mrimg --auto
SetupComplete.cmd
for automatic post-setup execution.