From 497905abb9e7d77eb45165760a11d01778a41811 Mon Sep 17 00:00:00 2001 From: dunix2000 Date: Mon, 22 Jun 2026 14:06:40 -0700 Subject: [PATCH 1/5] Crash detection and OS reinstall tool. --- .github/crashdetect/CrashDetectCreateUsb.cmd | 99 +++++++ .../crashdetect/CrashDetectOsReinstall.cmd | 258 +++++++++++++++++ .github/crashdetect/CrashDetectSetupGuide.md | 265 ++++++++++++++++++ .github/crashdetect/Unattend.xml | 64 +++++ 4 files changed, 686 insertions(+) create mode 100644 .github/crashdetect/CrashDetectCreateUsb.cmd create mode 100644 .github/crashdetect/CrashDetectOsReinstall.cmd create mode 100644 .github/crashdetect/CrashDetectSetupGuide.md create mode 100644 .github/crashdetect/Unattend.xml diff --git a/.github/crashdetect/CrashDetectCreateUsb.cmd b/.github/crashdetect/CrashDetectCreateUsb.cmd new file mode 100644 index 000000000..9048d4ad7 --- /dev/null +++ b/.github/crashdetect/CrashDetectCreateUsb.cmd @@ -0,0 +1,99 @@ +@echo off + +REM Environment setup. +echo Setting up environment for ADK tools... +cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools>" +call DandISetEnv.bat +echo Done setting up environment. + +REM Ask for the USB disk number displayed in Diskpart. +echo Displaying detected disk drives.. +echo Creating DiskPart script... +( +echo list disk +) > C:\diskpart.txt +diskpart /s C:\diskpart.txt +del C:\diskpart.txt +echo Note that Disk 0 is often the OS drive you do NOT want to format! +set /p USBDISK=Enter the Disk Number of the USB drive you want to make WinPE bootable: +echo Disk %USBDISK% selected. + +:dism +REM Update startnet.cmd autorun script in WinPE boot image (winpe.wim). +cd /d "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64" +echo Mounting WinPE image to modify... +md C:\WinPE_amd64\mount +Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" +echo Done mounting winpe.wim image. +echo Updating startnet.cmd autorun script in WinPE boot image... +( +echo wpeinit +echo. +echo @echo off +echo REM Find USB drive. +echo for %%%%D in (D E F G H I J K L M N O P Q R S T U V W Y Z^) do ^( +echo if exist %%%%D:Scripts\CrashDetectOsReinstall.cmd ^( +echo call %%%%D:Scripts\CrashDetectOsReinstall.cmd +echo goto EOF +echo ^) +echo ^) +) > "C:\WinPE_amd64\mount\Windows\System32\startnet.cmd" +echo Done adding CrashDetectOsReinstall.cmd to startnet.cmd. +echo Unmounting WinPE image with committed changes... +Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit +echo Done unmounting winpe.wim image. +rmdir /s /q "C:\WinPE_amd64" +echo Deleted old folder "C:\WinPE_amd64". + +REM Create a USB drive with WinPE and data partitions. +REM Warning! +echo( +echo WARNING!!!: VERIFY DISK %USBDISK% IS THE CORRECT USB DISK TO FORMAT! +choice /C YN /M "ARE YOU SURE YOU WANT TO FORMAT DISK %USBDISK%?" +echo( +if %errorlevel% equ 2 ( + echo You chose NO, exiting without touching USB key. + timeout 5 + exit + goto eof +) +if %errorlevel% equ 1 ( + echo You chose YES, proceeding with formatting USB key. +) + +echo Wiping out USB and creating 2 partitions... +echo Creating DiskPart script... +( +echo select disk %USBDISK% +echo clean +echo create partition primary size=2048 +echo active +echo format fs=FAT32 quick label="WinPE" +echo assign letter=P +echo create partition primary +echo format fs=NTFS quick label="WinUSB" +echo assign letter=U +) > C:\diskpart.txt +echo Partitioning USB... +diskpart /s C:\diskpart.txt +del C:\diskpart.txt +echo Done partitioning and formatting USB. + +REM Copy WinPE working files to working directory. +echo Copying WinPE working files to "C:\WinPE_amd64"... +call copype amd64 "C:\WinPE_amd64" +echo Done copying files. + +REM Install WinPE to the USB. +echo Creating bootable WinPE USB... +call Makewinpemedia /ufd /f C:\WinPE_amd64 P: /bootex +echo Done, WinPE USB drive is now bootable. + +REM Copy Unattend.xml, scripts and install.wim over to USB +echo Copying Unattend.xml and scripts over to USB... +xcopy "C:\WinPE_USB\Scripts\" "U:\Scripts\" /e /i +echo Copying install.wim over to USB...this could take a while... +xcopy "C:\WinPE_USB\Images\install.wim" "U:\Images\" /i +echo Done copying files. + +echo DONE CREATING BOOTABLE WINPE USB DRIVE! \ No newline at end of file diff --git a/.github/crashdetect/CrashDetectOsReinstall.cmd b/.github/crashdetect/CrashDetectOsReinstall.cmd new file mode 100644 index 000000000..faebb4432 --- /dev/null +++ b/.github/crashdetect/CrashDetectOsReinstall.cmd @@ -0,0 +1,258 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion + +echo CrashDetectOsReinstall.cmd...START + +echo Searching for the USB drive volume letter... +set "USB=" + +for %%D in (D E F G H I J K L M N O P Q R S T U V W Y Z) do ( + if exist "%%D:\Scripts\CrashDetectOsReinstall.cmd" ( + set "USB=%%D" + echo Found USB at drive volume letter !USB!: + ) +) + +if not defined USB ( + echo ERROR: Did not find USB drive volume letter + goto error +) + +if not exist "!USB!:\Logs" ( + echo Creating Logs directory on USB + mkdir "!USB!:\Logs" +) +set "LOG=!USB!:\Logs\CrashDetectOsReinstall.log" +echo Created log file "%LOG%" on USB +echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...START >> "%LOG%" +echo [%DATE% %TIME%] Found USB at drive volume letter !USB!: >> "%LOG%" + +set "FLAG_RETRIES=!USB!:\Logs\Retries.flg" +set "FLAG_INSTALLOS=!USB!:\Logs\InstallOs.flg" +set "FLAG_DEPLOYOSDONE=!USB!:\Logs\DeployOsDone.flg" + + +:installos +if exist "%FLAG_INSTALLOS%" ( + if exist "%FLAG_DEPLOYOSDONE%" ( + echo OS reinstall done. + echo [%DATE% %TIME%] OS reinstall done. >> "%LOG%" + del "%FLAG_INSTALLOS%" >> "%LOG%" 2>&1 + del "%FLAG_DEPLOYOSDONE%" >> "%LOG%" 2>&1 + goto reboot + ) + echo Reinstalling OS... + echo [%DATE% %TIME%] Reinstalling OS... >> "%LOG%" + goto deployos +) + + +:detectcrash +if exist "C:\Windows\Minidump\" ( + echo OS crashed on last reboot into the OS! + echo [%date% %time%] OS crashed on last reboot into the OS! >> "%LOG%" + + set "MININAME=" + for %%F in ("C:\Windows\Minidump\*.dmp") do ( + set "MININAME=%%~nF" + echo Minidump filename: !MININAME! >> "%LOG%" + ) + + echo Backing up Minidump files... + copy /y "C:\Windows\Minidump\*.dmp" "!USB!:\Logs" >> "%LOG%" 2>&1 + if !errorlevel! neq 0 ( + echo ERROR: Failed to back up Mini dump file + echo [%date% %time%] ERROR: Failed to back up Mini dump file >> "%LOG%" + ) + rmdir /s /q "C:\Windows\Minidump" >> "%LOG%" 2>&1 + if !errorlevel! neq 0 ( + echo ERROR: Failed to delete Minidump folder + echo [%date% %time%] Failed to delete Minidump folder >> "%LOG%" + ) + + if exist "C:\Windows\MEMORY.DMP" ( + if defined MININAME ( + ren "C:\Windows\MEMORY.DMP" "MEMORY-!MININAME!.DMP" >> "%LOG%" 2>&1 + ) + if !errorlevel! neq 0 ( + echo ERROR: Failed to rename MEMORY.DMP file + echo [%date% %time%] ERROR: Failed to rename MEMORY.DMP file >> "%LOG%" + echo Backing up MEMORY.DMP file... + copy /y "C:\Windows\MEMORY.DMP" "!USB!:\Logs" >> "%LOG%" 2>&1 + ) else ( + echo Backing up MEMORY-!MININAME!.DMP file... + copy /y "C:\Windows\MEMORY-!MININAME!.DMP" "!USB!:\Logs" >> "%LOG%" 2>&1 + ) + if !errorlevel! neq 0 ( + echo ERROR: Failed to back up MEMORY.DMP file + echo [%date% %time%] ERROR: Failed to back up MEMORY.DMP file >> "%LOG%" + ) + ) + + echo Done trying to back up files to USB + echo [%date% %time%] Done trying to back up files to USB >> "%LOG%" + goto retry +) else ( + rem If OS crashed just now, it will be detected on next reboot. + rem Minidump folder used for crash detection is not created yet on automatic first crash reboot until OS is loaded. + echo No OS crash on last reboot into the OS. + echo [%date% %time%] No OS crash on last reboot into the OS. >> "%LOG%" + if exist %FLAG_RETRIES% ( + del %FLAG_RETRIES% >> "%LOG%" 2>&1 + ) + goto reboot +) + + +:retry +set "TRIES=0" +rem Retries are always one less than actual crashes because first crash is not detected. +set "MAX_RETRIES=2" + +if not exist "%FLAG_RETRIES%" ( + echo Creating "%FLAG_RETRIES%" with default retries set to 0 >> "%LOG%" + echo RETRIES=0 > "%FLAG_RETRIES%" +) + +for /f "tokens=1,2 delims==" %%A in (%FLAG_RETRIES%) do ( + if /i "%%A"=="RETRIES" ( + set "TRIES=%%B" >> "%LOG%" 2>&1 + ) +) + +set /a TRIES+=0 2>nul >> "%LOG%" 2>&1 +set /a TRIES+=1 >> "%LOG%" 2>&1 +echo RETRIES=!TRIES! > %FLAG_RETRIES% + +echo Current OS boot retries: !TRIES! +echo Current OS boot retries: !TRIES! >> "%LOG%" +if !TRIES! GEQ %MAX_RETRIES% ( + echo Max %MAX_RETRIES% retries reached, reinstalling OS... + del %FLAG_RETRIES% >> "%LOG%" 2>&1 + type nul > %FLAG_INSTALLOS% + goto installos +) else ( + echo Max %MAX_RETRIES% retries allowed, booting into OS... + goto reboot +) + + +:deployos +rem Image index is the OS edition to install from a multi-edition OS install image. +rem For "Windows 11 25H2" image, "Windows 11 Pro" is the 6th item on the list of editions available. +rem Adjust accordingly to install other OS editions. +rem For single edition OS images, set index to 1. +set "IMAGE_INDEX=6" +set "TARGET_DISK=0" +set "SYSTEM_DRIVE=S" +set "SYSTEM_LABEL=System" +set "TARGET_DRIVE=W" +set "TARGET_LABEL=TestOS" +set "INSTALL_WIM=install.wim" +set "UNATTEND_XML=Unattend.xml" + +echo Setting flag InstallOs.flg for CrashDetectOsReinstall.cmd autorun script to detect OS install. >> "%LOG%" +type nul > "%FLAG_INSTALLOS%" + +echo [1/8] Creating DiskPart script... +echo [%DATE% %TIME%] [1/8] Creating DiskPart script... >> "%LOG%" +( +echo select disk "%TARGET_DISK%" +echo clean +echo convert gpt +echo create partition efi size=100 +echo format quick fs=fat32 label="%SYSTEM_LABEL%" +echo assign letter="%SYSTEM_DRIVE%" +echo create partition msr size=16 +echo create partition primary +echo format quick fs=ntfs label="%TARGET_LABEL%" +echo assign letter="%TARGET_DRIVE%" +) > X:\diskpart.txt + +echo [2/8] Partitioning target disk... +echo [%DATE% %TIME%] [2/8] Partitioning target disk... >> "%LOG%" +diskpart /s X:\diskpart.txt >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: DiskPart failed. See %LOG% + goto error +) + +echo [3/8] Applying OS WIM image... +echo [%DATE% %TIME%] [3/8] Applying image... >> "%LOG%" +dism /Apply-Image /ImageFile:"!USB!:\Images\%INSTALL_WIM%" /Index:"%IMAGE_INDEX%" /ApplyDir:"%TARGET_DRIVE%":\ >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: DISM apply failed. See %LOG% + goto error +) + +echo [4/8] Copying "%UNATTEND_XML%"... +echo [%DATE% %TIME%] [4/8] Copying %UNATTEND_XML%... >> "%LOG%" +if not exist "%TARGET_DRIVE%:\Windows\Panther" ( + mkdir "%TARGET_DRIVE%:\Windows\Panther" >> "%LOG%" 2>&1 +) +copy /y "!USB!:\Scripts\%UNATTEND_XML%" "%TARGET_DRIVE%:\Windows\Panther\%UNATTEND_XML%" >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: Failed to copy %UNATTEND_XML%. See %LOG% + echo [%DATE% %TIME%] ERROR: Failed to copy %UNATTEND_XML%. >> %LOG% + goto error +) + +echo [5/8] Creating boot files... +echo [%DATE% %TIME%] [5/8] Creating boot files... >> "%LOG%" +bcdboot W:\Windows /s S: /f UEFI >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: BCDBOOT failed. See %LOG% + goto error +) + +echo [6/8] Setting one-time bootsequence to OS boot manager... +echo [%DATE% %TIME%] [6/8] Setting one-time bootsequence to OS boot manager... >> "%LOG%" +bcdedit /set {fwbootmgr} bootsequence {bootmgr} +echo bcdedit /set {fwbootmgr} bootsequence {bootmgr} >> "%LOG%" +if errorlevel 1 ( + echo ERROR: BCDEDIT /set {fwbootmgr} bootsequence {bootmgr} failed. See "%LOG%" + goto error +) + +echo [7/8] Deployment complete. +echo [%DATE% %TIME%] [7/8] Deployment complete. >> "%LOG%" +echo Deployment complete. >> "%LOG%" +echo Setting flag DeployOsDone.flg for script to detect OS install complete and boot into OS. +type nul > "%FLAG_DEPLOYOSDONE%" + +echo [8/8] Rebooting into OS in 10sec... +echo [%DATE% %TIME%] [8/8] Rebooting into OS in 10sec... >> "%LOG%" +rem Simulate timeout with ping (10 sec) +ping -n 11 127.0.0.1 >nul +wpeutil reboot >> "%LOG%" 2>&1 + + +:reboot +echo Rebooting into OS in 10sec... +echo [%DATE% %TIME%] Rebooting into OS... >> "%LOG%" +rem Force next boot into Windows boot manager. +bcdedit /set {fwbootmgr} bootsequence {bootmgr} >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: BCDEDIT /set {fwbootmgr} bootsequence {bootmgr} - failed. See "%LOG%" + goto error +) +rem Disable WinRE prompt to attempt system recovery, which requires user intervention. +bcdedit /set {default} recoveryenabled no >> "%LOG%" 2>&1 +if errorlevel 1 ( + echo ERROR: BCDEDIT /set {default} recoveryenabled no - failed. See "%LOG%" +) +rem Simulate timeout with ping (10 sec) +ping -n 11 127.0.0.1 >nul +wpeutil reboot >> "%LOG%" 2>&1 + + +:error +echo CrashDetectOsReinstall.cmd...ERROR! See "%LOG%" +echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...ERROR! >> "%LOG%" +exit /b 1 >> "%LOG%" 2>&1 + + +:done +echo CrashDetectOsReinstall.cmd...DONE! +echo [%DATE% %TIME%] CrashDetectOsReinstall.cmd...DONE! >> "%LOG%" +exit /b 0 >> "%LOG%" 2>&1 diff --git a/.github/crashdetect/CrashDetectSetupGuide.md b/.github/crashdetect/CrashDetectSetupGuide.md new file mode 100644 index 000000000..dd04d0fad --- /dev/null +++ b/.github/crashdetect/CrashDetectSetupGuide.md @@ -0,0 +1,265 @@ +# Crash Detect USB Setup Guide: +# Automating Crash Detection and OS Reinstall of Target Test Systems + +--- + +## A) Overview + +This guide walks through setting up a new bootable WinPE USB drive using: + +- A **Host Controller** (to build the USB) +- A **bootable WinPE USB** (automatic crash detection and OS reinstall) +- A **target test system** + +### High-level flow + +1. Download Windows image (ISO) +2. Install Windows ADK + WinPE add-on +3. Create bootable WinPE USB +4. Copy image + scripts to USB +5. Boot up target system +6. OPTIONAL: Install OS on new Target System + +--- + +## B) Requirements + +### Host Controller +- Windows 11 25H2 +- Administrator privileges +- USB drive (>= 64GB recommended) +- Internet connection + +### Target System +- Windows 11 25H2 +- BIOS boot priority set to **USB boot** and **Secure Boot disabled** +- Windows System failure recovery set to **"Automatically restart"** +- Willing to wipe disk (automatic OS reinstall from crash) + +--- + +## C) Download Required Software and Scripts onto the Host Controller + +### Windows OS Image (ISO) + +- [Download Windows 11 (official)](https://www.microsoft.com/en-us/software-download/windows11) +- Go to section "Download Windows 11 Disk Image (ISO) for x64 devices". +- Select the option "Windows 11 (multi-edition ISO for x64 devices)". +- Click "Confirm" button. +- Section "Select the product language" should appear. +- Select your language option. (Ex: "English (United States)") +- Click "Confirm" button. +- Section "Download - Windows 11 English" should appear. +- Click "64-bit Download" button. +- In File Explorer, go to the location you downloaded the ISO file "Win11_25H2_English_x64_v2.iso" to. +- Right-click on the ISO file and select "Mount". + - If the "Open File - Security Warning" prompt pops up after a minute then click "Open". + - (The prompt may be hidden behind other Windows.) +- Create new folder and subfolder "C:\WinPE_USB\Images". +- Go to the "%MountDriveLetter%:\sources" folder and copy the **"install.wim"** file to **"C:\WinPE_USB\Images"**. + - This is the Windows 11 OS image file that the DISM tool will need to deploy the OS. + - This file will be copied over to the USB later after bootable WinPE USB creation. +- Right-click on the %MountDriveLetter% and select "Eject" to unmount the ISO image. + +--- + +### Windows Assessment and Deployment Kit (Deployment Tools) & Windows PE Add-on + +- [Download Windows ADK & WinPE Add-on](https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install) +- Go to section "Download the ADK 10.1.26100.2454 (December 2024)". +- Click on the link "Download the Windows ADK 10.1.26100.2454 (December 2024)" to download the "adksetup.exe" installer. +- Click on the link "Download the Windows PE add-on for the Windows ADK 10.1.26100.2454 (December 2024)" to download the "adkwinpesetup.exe" installer. +Install ADK: +- Double-click on the "adksetup.exe" from the location you downloaded the file to launch the installer. +- "Specify Location" page, click "Next", to install at default location. +- "Windows Kits Privacy" page, select your privacy option, click "Next". +- "License Agreement" page, click "Accept". +- "Select the features you want to install" page, confirm "Deployment Tools" is checked, then click "Install". +- If "User Account Control" prompt appears, click "Yes" to begin installation process. +- "Installing features..." page, wait for installation process to complete. +- "Welcome to the Windows Assessment and Deployment Kit!" page, click "Close". +Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on +- Double-click on the "adkwinpesetup.exe" from the location you downloaded the file to launch the installer. +- "Specify Location" page, click "Next", to install at default location. +- "Windows Kits Privacy" page, select your privacy option, click "Next". +- "License Agreement" page, click "Accept". +- "Select the features you want to install" page, confirm "Windows Preinstallation Environment (Windows PE)" is checked, then click "Install". +- If "User Account Control" prompt appears, click "Yes" to begin installation process. +- "Installing features..." page, wait for installation process to complete. +- "Welcome to the Windows Assessment and Deployment Kit Windows Preinstallation Environment Add-ons!" page, click "Close". + +--- + +### Unattend and Script Files from GitHub +- [Windows-driver-samples/tree/main/.github/crashdetect](https://github.com/microsoft/Windows-driver-samples/tree/main/.github/crashdetect) +- Create directory **"C:\WinPE_USB\Scripts\"** and copy the downloaded files here. + - CrashDetectCreateUsb.cmd + - CrashDetectOsReinstall.cmd + - Unattend.xml + +--- + +## D) Create Bootable WinPE USB + +- [Create bootable Windows PE media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive) +- **TIP:** It's a good idea to make a backup copy of the original **"winpe.wim"** image file before editing it in the following steps. +- Plug a USB into the Host Controller. + +- Confirm the folder **"C:\WinPE_USB"** and its subfolders **"Scripts"** and **"Images"** exist. +- Confirm the "Scripts" subfolder contains the following files that were downloaded from previous steps. +``` + CrashDetectOsReinstall.cmd + Unattend.xml +``` +- Confirm the "Images" subfolder contains the Win11 OS image file. +``` + install.wim +``` + +### OPTION 1: Use the "CrashDetectCreateUsb.cmd" script to create the USB automatically. + +- Start a "Command Prompt" running as administrator. +- Run the script by typing the following line into the Command Prompt. +``` + "C:\WinPE_USB\Scripts\CrashDetectCreateUsb.cmd" +``` +- The script will display a list of detected disk drives, usually Disk 0 is the OS disk, do not select that disk. +- Prompt 1: will ask you to enter the Disk number of your USB drive. +- Prompt 2: will confirm one last time before wiping out the USB drive. +- The last step will copy over the "install.wim" OS image to the USB, which could take a while. + +### OPTION 2: Follow the steps below to create the USB manually. + +#### 1. Make sure your PC has the ADK and ADK Windows PE add-on installed. + - Start the "Deployment and Imaging Tools Environment" running as administrator. + +#### 2. Update the "startnet.cmd" autorun script in the WinPE boot image. + - Mount the WinPE boot image (winpe.wim) using DISM. +```text + cd "..\Windows Preinstallation Environment\amd64" + md C:\WinPE_amd64\mount + Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" +``` + - Adds the "CrashDetectOsReinstall.cmd" script to the "startnet.cmd" script. +```text + ( + echo wpeinit + echo. + echo @echo off + echo REM Find USB drive. + echo for %%D in (D E F G H I J K L M N O P Q R S T U V W Y Z^) do ^( + echo if exist %%D:Scripts\CrashDetectOsReinstall.cmd ^( + echo call %%D:Scripts\CrashDetectOsReinstall.cmd + echo goto EOF + echo ^) + echo ^) + ) > "C:\WinPE_amd64\mount\Windows\System32\startnet.cmd" +``` + - Unmount the WinPE image using DISM. +```text + Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit +``` + - Delete folder "C:\WinPE_amd64", else the next step below will fail to copy PE files. +```text + rmdir /s /q "C:\WinPE_amd64" +``` + +#### 3. Create and format a multiple partition USB drive. + - [Create a multiple partition USB drive](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe--use-a-single-usb-key-for-winpe-and-a-wim-file---wim#option-1-create-a-multiple-partition-usb-drive) + - Attach a USB large enough for 2GB WinPE partition + WinUSB partition (Win11 WIM 8GB + Memory dump files 16GB-64GB + Scripts). + - Follow instructions for Option 1 on the following website to partition and format your USB drive. +```txt + diskpart + list disk + select disk X (where X is your USB drive) + clean + create partition primary size=2048 + active + format fs=FAT32 quick label="WinPE" + assign letter=P + create partition primary + format fs=NTFS quick label="WinUSB" + assign letter=U + exit +``` + +#### 4. Create a bootable Windows PE USB drive. + - Copying WinPE boot files to a working directory. +```txt + copype amd64 C:\WinPE_amd64 +``` + - Copy the WinPE files to the WinPE partition on USB. +```txt + MakeWinPEMedia /UFD C:\WinPE_amd64 P: /bootex +``` + +--- + +#### 5. Copy scripts and OS install image over to WinUSB partition on USB. + + - Copy Script files over to USB. +```txt + xcopy "C:\WinPE_USB\Scripts\" "U:\Scripts\" /e /i +``` + - Copy Windows 11 OS WIM file over to USB, this could take a while... +```txt + xcopy "C:\WinPE_USB\Images\install.wim" "U:\Images\" /i +``` + +--- + +## E) Boot Up Target System + +- Insert USB into target PC +- Power on +- Enter boot menu (F12 / ESC / DEL depending on vendor) +- Confirm BIOS/UEFI setting has USB Drive as the first boot priority. (Varies among vendors) +- Confirm Secure Boot setting is Disabled +- Save BIOS settings to reboot target system. +- WinPE will automatically launch the "startnet.cmd" script we edited earlier in the "winpe.wim" image. +- The script will call "wpeinit", then our "CrashDetectOsReinstall.cmd" script to begin automatic OS crash detection and reimage for WDK driver testing. + +--- + +## F). OPTIONAL: Install OS on new Target System +### - On the bootable USB's second partition "WinPE_USB" +- Create the folder **"Logs"**. +- Create an empty file **"InstallOs.flg"** in that folder. + - (In File Explorer, ensure file name extensions are visible, else the filename may be accidentally set to "InstallOs.flg.txt") +- Plug USB into target system and reboot into USB. +- The USB will detect the flag and begin reinstalling the OS immediately. + - **WARNING**: There will be **NO** prompt to reconfirm OS install, be sure to plug into the correct target system. + - Do **NOT** leave this USB plugged into the Host Controller when this flag is set, to avoid accidental OS reinstall. + +--- + +## Troubleshooting + +### USB won't boot +- Check BIOS boot order +- Disable Secure Boot if needed + +### Disk not visible in WinPE +- Missing storage drivers + +### Windows doesn't boot +- Re-run `bcdboot` +- Verify partition layout + +--- + +## Reference Documentation + +- [WinPE: Create bootable media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive) +- [WinPE overview](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-intro) +- [Capture and apply Windows (WIM)](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim) + +--- + +## Summary + +This setup uses: + +- **ADK + WinPE** -> build bootable environment +- **ISO** -> get Windows image +- **DISM + BCDBoot** -> deploy OS diff --git a/.github/crashdetect/Unattend.xml b/.github/crashdetect/Unattend.xml new file mode 100644 index 000000000..a235fba0d --- /dev/null +++ b/.github/crashdetect/Unattend.xml @@ -0,0 +1,64 @@ + + + + + + en-US + en-US + en-US + en-US + + + + + Pacific Standard Time + + + + true + true + true + true + true + Work + 3 + + + + + + admin + Administrators + + @Password123 + true</PlainText> + </Password> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + + <!-- Auto logon (lab only) --> + <AutoLogon> + <Username>admin</Username> + <Enabled>true</Enabled> + <Password> + <Value>@Password123</Value> + <PlainText>true</PlainText> + </Password> + <LogonCount>999</LogonCount> + </AutoLogon> + + </component> + </settings> + +</unattend> \ No newline at end of file From e1a7ad0aaa8bf4384d2d38c86fc657dc553b7b8e Mon Sep 17 00:00:00 2001 From: dunix2000 <dunix2000@gmail.com> Date: Thu, 25 Jun 2026 10:44:51 -0700 Subject: [PATCH 2/5] - Added pre-check of needed tools and files before starting script. - Added error checking for calls to scripts and tools and exit on error. - Defaulted drive letters to A: and B: to increase chance of avoiding conflicts. - Display proper message of whether USB was created correctly or not. --- .github/crashdetect/CrashDetectCreateUsb.cmd | 184 ++++++++++++++----- 1 file changed, 137 insertions(+), 47 deletions(-) diff --git a/.github/crashdetect/CrashDetectCreateUsb.cmd b/.github/crashdetect/CrashDetectCreateUsb.cmd index 9048d4ad7..571f03936 100644 --- a/.github/crashdetect/CrashDetectCreateUsb.cmd +++ b/.github/crashdetect/CrashDetectCreateUsb.cmd @@ -1,66 +1,112 @@ @echo off +setlocal -REM Environment setup. +set WINPE_DRIVE=A +set WINUSB_DRIVE=B +set EXITCODE=0 + +rem Pre-check +if not exist "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\DISM\dism.exe" ( + echo ERROR: Missing DISM tool! + goto error +) +if not exist "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim" ( + echo ERROR: Missing winpe.wim image! + goto error +) +if not exist "C:\WinPE_USB\Scripts\CrashDetectOsReinstall.cmd" ( + echo ERROR: Missing script C:\WinPE_USB\Scripts\CrashDetectOsReinstall.cmd! + goto error +) +if not exist "C:\WinPE_USB\Scripts\Unattend.xml" ( + echo ERROR: Missing XML C:\WinPE_USB\Scripts\Unattend.xml! + goto error +) +if not exist "C:\WinPE_USB\Images\install.wim" ( + echo ERROR: Missing WIM C:\WinPE_USB\Images\install.wim! + goto error +) + +rem Environment setup. echo Setting up environment for ADK tools... cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools>" call DandISetEnv.bat echo Done setting up environment. -REM Ask for the USB disk number displayed in Diskpart. +rem Ask for the USB disk number displayed in Diskpart. echo Displaying detected disk drives.. echo Creating DiskPart script... ( echo list disk -) > C:\diskpart.txt -diskpart /s C:\diskpart.txt -del C:\diskpart.txt +) > C:\WinPE_USB\diskpart.txt +diskpart /s C:\WinPE_USB\diskpart.txt +del C:\WinPE_USB\diskpart.txt +echo( +echo( echo Note that Disk 0 is often the OS drive you do NOT want to format! +echo( +echo Ensure drive letters %WINPE_DRIVE%: and %WINUSB_DRIVE%: are not currently assigned to other drives! +echo It's ok if it's assigned to the target USB. +echo( set /p USBDISK=Enter the Disk Number of the USB drive you want to make WinPE bootable: +echo( echo Disk %USBDISK% selected. +rem Create a USB drive with WinPE and data partitions. +echo( +echo WARNING!!!: VERIFY DISK %USBDISK% IS THE CORRECT USB DISK TO FORMAT! +choice /C YN /M "ARE YOU SURE YOU WANT TO FORMAT DISK %USBDISK%?" +echo( +if %errorlevel% equ 2 ( + echo You chose NO, exiting without modifying USB key. + exit /b 0 +) +if %errorlevel% equ 1 ( + echo You chose YES, proceeding with formatting USB key. +) + :dism -REM Update startnet.cmd autorun script in WinPE boot image (winpe.wim). +rem Update startnet.cmd autorun script in WinPE boot image (winpe.wim). cd /d "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64" +echo( +if not exist "C:\WinPE_USB\WinPE_amd64\mount" ( + echo Creating temp folders C:\WinPE_USB\WinPE_amd64\mount... + mkdir "C:\WinPE_USB\WinPE_amd64\mount" +) echo Mounting WinPE image to modify... -md C:\WinPE_amd64\mount -Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" +Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" +if errorlevel 1 ( + echo ERROR: DISM failed to mount ImageFile:"en-us\winpe.wim"! + goto error +) echo Done mounting winpe.wim image. echo Updating startnet.cmd autorun script in WinPE boot image... ( echo wpeinit echo. echo @echo off -echo REM Find USB drive. +echo rem Find USB drive. echo for %%%%D in (D E F G H I J K L M N O P Q R S T U V W Y Z^) do ^( echo if exist %%%%D:Scripts\CrashDetectOsReinstall.cmd ^( echo call %%%%D:Scripts\CrashDetectOsReinstall.cmd echo goto EOF echo ^) echo ^) -) > "C:\WinPE_amd64\mount\Windows\System32\startnet.cmd" +) > "C:\WinPE_USB\WinPE_amd64\mount\Windows\System32\startnet.cmd" echo Done adding CrashDetectOsReinstall.cmd to startnet.cmd. echo Unmounting WinPE image with committed changes... -Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit +Dism /Unmount-Image /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" /commit +if errorlevel 1 ( + echo ERROR: DISM failed to unmount ImageFile:"en-us\winpe.wim"! + echo USB drive have not been touched yet. + goto error +) echo Done unmounting winpe.wim image. -rmdir /s /q "C:\WinPE_amd64" -echo Deleted old folder "C:\WinPE_amd64". -REM Create a USB drive with WinPE and data partitions. -REM Warning! +rem Delete temp "WinPE_amd64" folder, else the "copype.cmd" below will fail if the folder is already present. +rmdir /s /q "C:\WinPE_USB\WinPE_amd64" +echo Deleted temp folder "C:\WinPE_USB\WinPE_amd64". echo( -echo WARNING!!!: VERIFY DISK %USBDISK% IS THE CORRECT USB DISK TO FORMAT! -choice /C YN /M "ARE YOU SURE YOU WANT TO FORMAT DISK %USBDISK%?" -echo( -if %errorlevel% equ 2 ( - echo You chose NO, exiting without touching USB key. - timeout 5 - exit - goto eof -) -if %errorlevel% equ 1 ( - echo You chose YES, proceeding with formatting USB key. -) - echo Wiping out USB and creating 2 partitions... echo Creating DiskPart script... ( @@ -69,31 +115,75 @@ echo clean echo create partition primary size=2048 echo active echo format fs=FAT32 quick label="WinPE" -echo assign letter=P +echo assign letter=%WINPE_DRIVE% echo create partition primary echo format fs=NTFS quick label="WinUSB" -echo assign letter=U -) > C:\diskpart.txt +echo assign letter=%WINUSB_DRIVE% +) > C:\WinPE_USB\diskpart.txt echo Partitioning USB... -diskpart /s C:\diskpart.txt -del C:\diskpart.txt +diskpart /s C:\WinPE_USB\diskpart.txt +if errorlevel 1 ( + echo ERROR: DiskPart failed during partitioning and formatting USB! + del C:\WinPE_USB\diskpart.txt + goto error +) +del C:\WinPE_USB\diskpart.txt echo Done partitioning and formatting USB. - -REM Copy WinPE working files to working directory. -echo Copying WinPE working files to "C:\WinPE_amd64"... -call copype amd64 "C:\WinPE_amd64" -echo Done copying files. - -REM Install WinPE to the USB. +echo( +rem The "copype.cmd" script will create working directory "WinPE_amd64", it will fail if directory already exist. +echo Copying WinPE working files to "C:\WinPE_USB\WinPE_amd64"... +call copype.cmd amd64 "C:\WinPE_USB\WinPE_amd64" +if errorlevel 1 ( + echo ERROR: Script "copype.cmd" failed to copy working files! + goto error +) +echo Done copying WinPE files. +echo( +rem Install WinPE to the USB and make it bootable. echo Creating bootable WinPE USB... -call Makewinpemedia /ufd /f C:\WinPE_amd64 P: /bootex +call Makewinpemedia.cmd /ufd /f "C:\WinPE_USB\WinPE_amd64" "%WINPE_DRIVE%:" /bootex +if errorlevel 1 ( + echo ERROR: Script "Makewinpemedia.cmd" failed to make WinPE USB bootable! + goto error +) echo Done, WinPE USB drive is now bootable. - -REM Copy Unattend.xml, scripts and install.wim over to USB +echo( +rem Copy Unattend.xml, scripts and install.wim over to USB echo Copying Unattend.xml and scripts over to USB... -xcopy "C:\WinPE_USB\Scripts\" "U:\Scripts\" /e /i +xcopy "C:\WinPE_USB\Scripts\" "%WINUSB_DRIVE%:\Scripts\" /E /I /R /Y +if errorlevel 1 ( + echo ERROR: Failed copying scripts from "C:\WinPE_USB\Scripts\" to USB! + goto error +) +echo Done copying script files. +echo( echo Copying install.wim over to USB...this could take a while... -xcopy "C:\WinPE_USB\Images\install.wim" "U:\Images\" /i -echo Done copying files. +robocopy "C:\WinPE_USB\Images" "%WINUSB_DRIVE%:\Images" install.wim /ETA /J +if %errorlevel% geq 8 ( + echo ERROR: Failed copying install.wim from "C:\WinPE_USB\Images\" to USB! + goto error +) +echo Done copying WIM file. +echo( +goto cleanup + +:error +set EXITCODE=1 +goto cleanup -echo DONE CREATING BOOTABLE WINPE USB DRIVE! \ No newline at end of file +:cleanup +rem Clean up any temp folders. +if exist "C:\WinPE_USB\WinPE_amd64" ( + rmdir /s /q "C:\WinPE_USB\WinPE_amd64" + echo Cleaned up temp folder "C:\WinPE_USB\WinPE_amd64". +) + +:done +if %EXITCODE% equ 0 ( + echo( + echo SUCCESSFULLY CREATED BOOTABLE WINPE USB DRIVE. +) else ( + echo( + echo FAILED CREATING BOOTABLE WINPE USB DRIVE! +) +endlocal & exit /b %EXITCODE% \ No newline at end of file From 5602082b35d0dd1e28b7c312778d65f9d7738fe3 Mon Sep 17 00:00:00 2001 From: dunix2000 <dunix2000@gmail.com> Date: Thu, 25 Jun 2026 12:22:58 -0700 Subject: [PATCH 3/5] - Updated the manual USB creation instructions to match the updated script. - Added section G) OPTIONAL: Add a Custom Script to Windows Setup. - Removed Create Bootable WinPE USB link from section D). --- .github/crashdetect/CrashDetectSetupGuide.md | 74 ++++++++++---------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/.github/crashdetect/CrashDetectSetupGuide.md b/.github/crashdetect/CrashDetectSetupGuide.md index dd04d0fad..56028f47f 100644 --- a/.github/crashdetect/CrashDetectSetupGuide.md +++ b/.github/crashdetect/CrashDetectSetupGuide.md @@ -91,8 +91,8 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- ### Unattend and Script Files from GitHub -- [Windows-driver-samples/tree/main/.github/crashdetect](https://github.com/microsoft/Windows-driver-samples/tree/main/.github/crashdetect) -- Create directory **"C:\WinPE_USB\Scripts\"** and copy the downloaded files here. +- Download files from [Windows-driver-samples/tree/main/.github/crashdetect](https://github.com/microsoft/Windows-driver-samples/tree/main/.github/crashdetect) +- Create directory **"C:\WinPE_USB\Scripts\"** and copy the following downloaded files to there. - CrashDetectCreateUsb.cmd - CrashDetectOsReinstall.cmd - Unattend.xml @@ -100,18 +100,18 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- ## D) Create Bootable WinPE USB - -- [Create bootable Windows PE media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive) - **TIP:** It's a good idea to make a backup copy of the original **"winpe.wim"** image file before editing it in the following steps. -- Plug a USB into the Host Controller. + - C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim +- Plug a USB into the Host Controller. +- Check to make sure drive letters **A:** and **B:** are not currently used by any other drive. If used by the target USB, it's okay. - Confirm the folder **"C:\WinPE_USB"** and its subfolders **"Scripts"** and **"Images"** exist. -- Confirm the "Scripts" subfolder contains the following files that were downloaded from previous steps. +- Confirm the **"Scripts"** subfolder contains the following files that were downloaded from previous steps. ``` CrashDetectOsReinstall.cmd Unattend.xml ``` -- Confirm the "Images" subfolder contains the Win11 OS image file. +- Confirm the **"Images"** subfolder contains the Win11 OS image file. ``` install.wim ``` @@ -137,8 +137,8 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on - Mount the WinPE boot image (winpe.wim) using DISM. ```text cd "..\Windows Preinstallation Environment\amd64" - md C:\WinPE_amd64\mount - Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" + md C:\WinPE_USB\WinPE_amd64\mount + Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" ``` - Adds the "CrashDetectOsReinstall.cmd" script to the "startnet.cmd" script. ```text @@ -153,15 +153,15 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on echo goto EOF echo ^) echo ^) - ) > "C:\WinPE_amd64\mount\Windows\System32\startnet.cmd" + ) > "C:\WinPE_USB\WinPE_amd64\mount\Windows\System32\startnet.cmd" ``` - Unmount the WinPE image using DISM. ```text - Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit + Dism /Unmount-Image /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" /commit ``` - - Delete folder "C:\WinPE_amd64", else the next step below will fail to copy PE files. + - Delete folder "C:\WinPE_USB\WinPE_amd64", else the "copype.cmd" below will fail if the folder is already present. ```text - rmdir /s /q "C:\WinPE_amd64" + rmdir /s /q "C:\WinPE_USB\WinPE_amd64" ``` #### 3. Create and format a multiple partition USB drive. @@ -176,21 +176,21 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on create partition primary size=2048 active format fs=FAT32 quick label="WinPE" - assign letter=P + assign letter=A create partition primary format fs=NTFS quick label="WinUSB" - assign letter=U + assign letter=B exit ``` #### 4. Create a bootable Windows PE USB drive. - Copying WinPE boot files to a working directory. ```txt - copype amd64 C:\WinPE_amd64 + copype.cmd amd64 "C:\WinPE_USB\WinPE_amd64" ``` - Copy the WinPE files to the WinPE partition on USB. ```txt - MakeWinPEMedia /UFD C:\WinPE_amd64 P: /bootex + MakeWinPEMedia.cmd /UFD /F "C:\WinPE_USB\WinPE_amd64" "A:" /bootex ``` --- @@ -199,11 +199,11 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on - Copy Script files over to USB. ```txt - xcopy "C:\WinPE_USB\Scripts\" "U:\Scripts\" /e /i + xcopy "C:\WinPE_USB\Scripts\" "B:\Scripts\" /E /I /R /Y ``` - Copy Windows 11 OS WIM file over to USB, this could take a while... ```txt - xcopy "C:\WinPE_USB\Images\install.wim" "U:\Images\" /i + robocopy "C:\WinPE_USB\Images" "B:\Images" install.wim /ETA /J ``` --- @@ -221,8 +221,8 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- -## F). OPTIONAL: Install OS on new Target System -### - On the bootable USB's second partition "WinPE_USB" +## F) OPTIONAL: Install OS on new Target System +### On the bootable USB's second partition "WinPE_USB" - Create the folder **"Logs"**. - Create an empty file **"InstallOs.flg"** in that folder. - (In File Explorer, ensure file name extensions are visible, else the filename may be accidentally set to "InstallOs.flg.txt") @@ -233,33 +233,35 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- -## Troubleshooting +## G) OPTIONAL: Add a Custom Script to Windows Setup +### Setupcomplete.cmd and ErrorHandler.cmd +- These are custom scripts that run during or after the Windows Setup process. They can be used to install applications or run other tasks by using cscript/wscript scripts. +- Follow instructions on this website: + - (https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup) -### USB won't boot -- Check BIOS boot order -- Disable Secure Boot if needed +--- +## Troubleshooting +### USB won't boot +- Check BIOS boot order +- Disable Secure Boot ### Disk not visible in WinPE -- Missing storage drivers - +- Missing storage drivers ### Windows doesn't boot -- Re-run `bcdboot` -- Verify partition layout +- Re-run `bcdboot` +- Verify partition layout --- ## Reference Documentation - -- [WinPE: Create bootable media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive) - [WinPE overview](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-intro) +- [WinPE: Create bootable media](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive) - [Capture and apply Windows (WIM)](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim) --- ## Summary - This setup uses: - -- **ADK + WinPE** -> build bootable environment -- **ISO** -> get Windows image -- **DISM + BCDBoot** -> deploy OS +- **ADK + WinPE** -> build bootable environment +- **ISO** -> get Windows image +- **DISM + BCDBoot** -> deploy OS \ No newline at end of file From 3df41b0d98b8a057c12670fe447f9ad64e99bd22 Mon Sep 17 00:00:00 2001 From: dunix2000 <dunix2000@gmail.com> Date: Thu, 25 Jun 2026 16:22:16 -0700 Subject: [PATCH 4/5] - Added resolution if "bootsect.exe" fails due to Windows Security block. --- .github/crashdetect/CrashDetectSetupGuide.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/crashdetect/CrashDetectSetupGuide.md b/.github/crashdetect/CrashDetectSetupGuide.md index 56028f47f..911357959 100644 --- a/.github/crashdetect/CrashDetectSetupGuide.md +++ b/.github/crashdetect/CrashDetectSetupGuide.md @@ -242,6 +242,17 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- ## Troubleshooting +### ERROR: Script "Makewinpemedia.cmd" failed to make WinPE USB bootable! +- If your Host Controller is connected to a secured IT network, the actions in this script may have been blocked. +- Check to see if **"bootsect.exe"** was blocked by Windows Security. +```txt + - Run "Windows Security" + - Select "Virus & threat protection" + - Click link "Manage ransomware protection" at the bottom + - Click link "Allow an app through Controlled folder access" + - Click button "Add an allowed app" button, then select option "Recently blocked apps" + - Scroll down and look for the "bootsect.exe" app to add to allow list +``` ### USB won't boot - Check BIOS boot order - Disable Secure Boot From 0592e5dd7118f3e97c5f885b42fc99d6f310e55e Mon Sep 17 00:00:00 2001 From: dunix2000 <dunix2000@gmail.com> Date: Thu, 25 Jun 2026 17:21:55 -0700 Subject: [PATCH 5/5] - Updated formatting of H1 Title, names of folders, scripts and programs. --- .github/crashdetect/CrashDetectSetupGuide.md | 73 ++++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/.github/crashdetect/CrashDetectSetupGuide.md b/.github/crashdetect/CrashDetectSetupGuide.md index 911357959..c41b8d589 100644 --- a/.github/crashdetect/CrashDetectSetupGuide.md +++ b/.github/crashdetect/CrashDetectSetupGuide.md @@ -1,5 +1,4 @@ -# Crash Detect USB Setup Guide: -# Automating Crash Detection and OS Reinstall of Target Test Systems +# Crash Detect USB Setup Guide: <br>Automating Crash Detection and OS Reinstall of Target Test Systems --- @@ -51,12 +50,14 @@ This guide walks through setting up a new bootable WinPE USB drive using: - Click "Confirm" button. - Section "Download - Windows 11 English" should appear. - Click "64-bit Download" button. -- In File Explorer, go to the location you downloaded the ISO file "Win11_25H2_English_x64_v2.iso" to. + +Mount ISO: +- In File Explorer, go to the location you downloaded the ISO file `Win11_25H2_English_x64_v2.iso` to. - Right-click on the ISO file and select "Mount". - If the "Open File - Security Warning" prompt pops up after a minute then click "Open". - (The prompt may be hidden behind other Windows.) -- Create new folder and subfolder "C:\WinPE_USB\Images". -- Go to the "%MountDriveLetter%:\sources" folder and copy the **"install.wim"** file to **"C:\WinPE_USB\Images"**. +- Create new folder and subfolder `C:\WinPE_USB\Images`. +- Go to the `%MountDriveLetter%:\sources` folder and copy the **`install.wim`** file to **`C:\WinPE_USB\Images`**. - This is the Windows 11 OS image file that the DISM tool will need to deploy the OS. - This file will be copied over to the USB later after bootable WinPE USB creation. - Right-click on the %MountDriveLetter% and select "Eject" to unmount the ISO image. @@ -67,10 +68,11 @@ This guide walks through setting up a new bootable WinPE USB drive using: - [Download Windows ADK & WinPE Add-on](https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install) - Go to section "Download the ADK 10.1.26100.2454 (December 2024)". -- Click on the link "Download the Windows ADK 10.1.26100.2454 (December 2024)" to download the "adksetup.exe" installer. -- Click on the link "Download the Windows PE add-on for the Windows ADK 10.1.26100.2454 (December 2024)" to download the "adkwinpesetup.exe" installer. +- Click on the link "Download the Windows ADK 10.1.26100.2454 (December 2024)" to download the `adksetup.exe` installer. +- Click on the link "Download the Windows PE add-on for the Windows ADK 10.1.26100.2454 (December 2024)" to download the `adkwinpesetup.exe` installer. + Install ADK: -- Double-click on the "adksetup.exe" from the location you downloaded the file to launch the installer. +- Double-click on the `adksetup.exe` from the location you downloaded the file to launch the installer. - "Specify Location" page, click "Next", to install at default location. - "Windows Kits Privacy" page, select your privacy option, click "Next". - "License Agreement" page, click "Accept". @@ -78,8 +80,9 @@ Install ADK: - If "User Account Control" prompt appears, click "Yes" to begin installation process. - "Installing features..." page, wait for installation process to complete. - "Welcome to the Windows Assessment and Deployment Kit!" page, click "Close". -Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on -- Double-click on the "adkwinpesetup.exe" from the location you downloaded the file to launch the installer. + +Install WinPE Add-on: <br>**Important:** Install **ADK first**, then WinPE add-on +- Double-click on the `adkwinpesetup.exe` from the location you downloaded the file to launch the installer. - "Specify Location" page, click "Next", to install at default location. - "Windows Kits Privacy" page, select your privacy option, click "Next". - "License Agreement" page, click "Accept". @@ -92,10 +95,10 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on ### Unattend and Script Files from GitHub - Download files from [Windows-driver-samples/tree/main/.github/crashdetect](https://github.com/microsoft/Windows-driver-samples/tree/main/.github/crashdetect) -- Create directory **"C:\WinPE_USB\Scripts\"** and copy the following downloaded files to there. - - CrashDetectCreateUsb.cmd - - CrashDetectOsReinstall.cmd - - Unattend.xml +- Create directory **`C:\WinPE_USB\Scripts\`** and copy the following downloaded files to there. + - `CrashDetectCreateUsb.cmd` + - `CrashDetectOsReinstall.cmd` + - `Unattend.xml` --- @@ -105,20 +108,16 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on - Plug a USB into the Host Controller. - Check to make sure drive letters **A:** and **B:** are not currently used by any other drive. If used by the target USB, it's okay. -- Confirm the folder **"C:\WinPE_USB"** and its subfolders **"Scripts"** and **"Images"** exist. -- Confirm the **"Scripts"** subfolder contains the following files that were downloaded from previous steps. -``` - CrashDetectOsReinstall.cmd - Unattend.xml -``` -- Confirm the **"Images"** subfolder contains the Win11 OS image file. -``` - install.wim -``` +- Confirm the folder **`C:\WinPE_USB`** and its subfolders **`Scripts`** and **`Images`** exist. +- Confirm the **`Scripts`** subfolder contains the following files that were downloaded from previous steps. + `CrashDetectOsReinstall.cmd` + `Unattend.xml` +- Confirm the **`Images`** subfolder contains the Win11 OS image file. + `install.wim` -### OPTION 1: Use the "CrashDetectCreateUsb.cmd" script to create the USB automatically. +### OPTION 1: Use the `CrashDetectCreateUsb.cmd` script to create the USB automatically. -- Start a "Command Prompt" running as administrator. +- Start a `Command Prompt` running as administrator. - Run the script by typing the following line into the Command Prompt. ``` "C:\WinPE_USB\Scripts\CrashDetectCreateUsb.cmd" @@ -126,21 +125,21 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on - The script will display a list of detected disk drives, usually Disk 0 is the OS disk, do not select that disk. - Prompt 1: will ask you to enter the Disk number of your USB drive. - Prompt 2: will confirm one last time before wiping out the USB drive. -- The last step will copy over the "install.wim" OS image to the USB, which could take a while. +- The last step will copy over the `install.wim` OS image to the USB, which could take a while. ### OPTION 2: Follow the steps below to create the USB manually. #### 1. Make sure your PC has the ADK and ADK Windows PE add-on installed. - - Start the "Deployment and Imaging Tools Environment" running as administrator. + - Start the `Deployment and Imaging Tools Environment` running as administrator. -#### 2. Update the "startnet.cmd" autorun script in the WinPE boot image. - - Mount the WinPE boot image (winpe.wim) using DISM. +#### 2. Update the `startnet.cmd` autorun script in the WinPE boot image. + - Mount the WinPE boot image (`winpe.wim`) using DISM. ```text cd "..\Windows Preinstallation Environment\amd64" - md C:\WinPE_USB\WinPE_amd64\mount + mkdir "C:\WinPE_USB\WinPE_amd64\mount" Dism /Mount-Image /ImageFile:"en-us\winpe.wim" /index:1 /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" ``` - - Adds the "CrashDetectOsReinstall.cmd" script to the "startnet.cmd" script. + - Adds the `CrashDetectOsReinstall.cmd` script to the `startnet.cmd` script. ```text ( echo wpeinit @@ -159,7 +158,7 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on ```text Dism /Unmount-Image /MountDir:"C:\WinPE_USB\WinPE_amd64\mount" /commit ``` - - Delete folder "C:\WinPE_USB\WinPE_amd64", else the "copype.cmd" below will fail if the folder is already present. + - Delete folder `C:\WinPE_USB\WinPE_amd64`, else the `copype.cmd` below will fail if the folder is already present. ```text rmdir /s /q "C:\WinPE_USB\WinPE_amd64" ``` @@ -222,10 +221,10 @@ Install WinPE Add-on: **Important:** Install **ADK first**, then WinPE add-on --- ## F) OPTIONAL: Install OS on new Target System -### On the bootable USB's second partition "WinPE_USB" -- Create the folder **"Logs"**. -- Create an empty file **"InstallOs.flg"** in that folder. - - (In File Explorer, ensure file name extensions are visible, else the filename may be accidentally set to "InstallOs.flg.txt") +### On the bootable USB's second partition `WinPE_USB` +- Create the folder **`Logs`**. +- Create an empty file **`InstallOs.flg`** in that folder. + - (In File Explorer, ensure file name extensions are visible, else the filename may be accidentally set to `InstallOs.flg.txt`) - Plug USB into target system and reboot into USB. - The USB will detect the flag and begin reinstalling the OS immediately. - **WARNING**: There will be **NO** prompt to reconfirm OS install, be sure to plug into the correct target system.