- Joined
- Mar 14, 2023
- Messages
- 100,258
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
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-BFD50179D6ACmarks 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.wimfile 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.xmlunder thewindowsPEpass.
See Also:
- Automated tools like DISMTools can generate this disk layout via a guided wizard if you’re not comfortable editing XML manually.
- Thread Author
-
- #3
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-BFD50179D6ACmarks 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.wimfile 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.xmlunder thewindowsPEpass.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.
i need a reg or cmd to put on autounattend site
Attachments
- Joined
- Mar 14, 2023
- Messages
- 100,258
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:
Key Details:
Place this in a batch file (e.g.,
Let me know if you need the exact
- 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> in OOBE or specialize pass, like so:
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>
- No registry hack is required:
reagentcconfigures all necessary values. - WinRE will be enabled for recovery operations if the partition and WIM exist.
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 the specialize pass or want details for applying this on custom partition paths!- Thread Author
-
- #5
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>inOOBEorspecializepass, 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:
reagentcconfigures 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 /enableSetupComplete.cmdor as a synchronous command in the answer file post-install pass).
Let me know if you need the exact<RunSynchronous>example for thespecializepass or want details for applying this on custom partition paths!
do you mean this way first login both script in cmd
Attachments
- Joined
- Mar 14, 2023
- Messages
- 100,258
Yes, that's correct! You can run both the WinRE registration script and the full system image backup script at first login (using
Alternative: Place Both Scripts in
If you use a batch file (e.g.,
Either method works—it’s just a matter of which phase of unattended setup you prefer.
If you want these commands as a single
Let me know if you need these adjusted for a network drive, specific partition ID, or for the
<FirstLogonCommands> in your autounattend.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 SetupComplete.cmd
If you use a batch file (e.g., 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 with SetupComplete.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 the specialize pass.- Thread Author
-
- #7
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.cmdC:\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.cmdfile, you can copy/paste them straight into a batch file to use withSetupComplete.cmdor 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 thespecializepass.
i tried and it doesn't work the script stop working
- Joined
- Mar 14, 2023
- Messages
- 100,258
If the script is stopping or failing when run during Windows Setup (via
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!
FirstLogonCommands or SetupComplete.cmd), here are the most common reasons and troubleshooting steps:1. Permissions & Timing
- Some commands (especially
wbadminandreagentc) require elevated permissions or may not work at the very first logon if the system isn’t fully set up yet. SetupComplete.cmdruns 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 wbadmincannot 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.wimisn't present,copyorreagentcwill error out. - Syntax problems: Some commands need full paths, and you may need to use
callorstartfor 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
wbadmincan 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.wimand make sure your backup target (D:or network share) exists and is writeable.
Recommendations:
- 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!
- Thread Author
-
- #9
If the script is stopping or failing when run during Windows Setup (viaFirstLogonCommandsorSetupComplete.cmd), here are the most common reasons and troubleshooting steps:
1. Permissions & Timing
- Some commands (especially
wbadminandreagentc) require elevated permissions or may not work at the very first logon if the system isn’t fully set up yet.SetupComplete.cmdruns 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 wbadmincannot 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.wimisn't present,copyorreagentcwill error out.- Syntax problems: Some commands need full paths, and you may need to use
callorstartfor 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
wbadmincan 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 -quiet5. 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.wimand 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!
should i put this with the other script
- Joined
- Mar 14, 2023
- Messages
- 100,258
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 (
How to use:
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) 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, orwbadminis 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
FirstLogonCommandsor 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.
- Thread Author
-
- #12
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.cmdor 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, orwbadminis 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
FirstLogonCommandsor 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.
it doesn't work do you sometimes have a screenshot of
- Joined
- Mar 14, 2023
- Messages
- 100,258
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 you want visuals:
You can search for screenshots of
If you attach or copy the actual log/output (or the error you see), I can give you step-by-step targeted help!
What to expect when using the script:
- 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”).
C:\setup_log.txtwill 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.cmdor your unattend file.
- 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.cmdis 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).
- Check that your
If you want visuals:
You can search for screenshots of
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.If you attach or copy the actual log/output (or the error you see), I can give you step-by-step targeted help!
- Thread Author
-
- #14
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.txtwill 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.cmdor 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.cmdis 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.txtoutput 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!
what is the full script for recovery and backup for where i should put it for windows 11 home
Attachments
- Joined
- Mar 14, 2023
- Messages
- 100,258
Here is the most complete script for recovery environment registration and user-data backup that will work on Windows 11 Home. Please note that Windows 11 Home does not support full system image backup via
Summary:
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).Example Batch Script: Recovery and User Data Backup
Code:
[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%
How to Use
- Save the script as:
C:\Windows\Setup\Scripts\SetupComplete.cmd- Create the folder if it does not exist.
- Backup destination:
- The above script copies user profiles to
D:\UserBackup. ChangeD:to any external or second internal drive with enough space. - If you don’t have a
D:drive, update to another drive letter, network share, or USB drive.
- The above script copies user profiles to
- Review the log:
- After setup, check
C:\setup_log.txtfor errors and results.
- After setup, check
Notes
- This is not a true system image backup. For that, you would need to use a third-party backup tool (such as Macrium Reflect, AOMEI, or similar) which you can also call at the end of this script if you silently install those tools.
reagentccommands are included to ensure the recovery environment is registered and enabled.xcopyis used for user profile data backup, which is the closest built-in equivalent to a full backup for Home editions.
If You Need Full System Image Backup on Home Edition
- You must download/install and silently invoke a tool like:
- Macrium Reflect Free or Paid:
Example silent backup command:
"C:\Program Files\Macrium\Reflect\Reflect.exe" -e -w -full -img D:\Backup\WinHomeBackup.mrimg --auto - AOMEI Backupper Standard (free for personal use).
- Acronis, EaseUS, etc. (many have silent command-line options).
- Macrium Reflect Free or Paid:
Summary:
- Place this script as
SetupComplete.cmdfor automatic post-setup execution. - It registers WinRE and copies user profiles for backup on Windows 11 Home.
- For true full-system backup, use a third-party backup tool in similar fashion.
Similar threads
- Replies
- 0
- Views
- 102