[Improved] USB Pe Tool

Discussion in 'Application Software' started by Dark Dinosaur, Jul 30, 2022.

  1. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    #1 Dark Dinosaur, Jul 30, 2022
    Last edited: Feb 18, 2023
    Something that I build for private usage
    I can call it 'alternative' to rufus, but for Windows system only
    Need windows 10+, since it involved lot of P/S code,
    I am not sure how much it compliable with lower P/S version
    can Accept Disk ID / Disk Letter, Source As path, ISO
    and it smart enough verify Source is not the Target, Target Is a Removable drive
    ( it not easy to create proper GPT partition in USB, on live System, with custom letter )

    what it can do, example.
    "USB Pe Tool" 3 c:\somefolder
    "USB Pe Tool" e: c:\somefolder\someiso.iso
    "USB Pe Tool" e: c:\somefolder\someiso.iso -TPM || bypass TPM Req.
    "USB Pe Tool" 2 c:\somefolder\someiso.iso -PE || Live install, Create Proper GPT partition

    ## Need to place wim-lib in Windows directory \ script directory

    Code:
    Usage:
    Run from Removeable Drive  [ -USB ]
    Run With Parameters        [ LETTER / DISK ID ] [ ISO File / Setup Folder ] [-TPM ~ Optional] [-PE ~ Optional]
    Run from Source Folder     [ Target Drive ]
    
    -TPM --- Bypass the TPM 2.0 Requirement
    -PE  --- WinPE Live From USB, 16GB DOK Or more IS needed
    
    Available USB DISK
    
    Disk - 3 , Total - 7.4716796875
    
    Waiting for 6 seconds, press CTRL+C to quit ...
    
    
    Changes. (18/02/2023)
    Code:
    - Add new [Un-Safe] edition for detection any drive
      (to use from live PE etc ...)
    - Add helper tool for (-pe) option,
      will copy OEM folder content to selected drive
    
    # Guide

    Create bootable UEFI Windows Setup on External drive / USB
    Code:
    "usb pe tool" 2  d:\setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso
    
    Code:
    Stop ShellHWDetection Service
    Define Drive Letter
    Verify variables
    $$$$$ Using [d:\Setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso] as Source
    $$$$$ Mount [d:\Setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso] to [E:]
    Check for local install
    Check User Input
    Format Usb Drive as NTFS
    
    Remove old BCD store entries
    
    Creating BCD entry for Windows Setup [boot\bcd]
    Creating ramdisksdidevice entry...
    Adding RAM Boot Windows Setup entry
    
    Creating BCD entry for Windows Setup [EFI\Microsoft\boot\bcd]
    Creating ramdisksdidevice entry...
    Adding RAM Boot Windows Setup entry
    
    Set legacy boot
    Update Boot Sector
    
    Copy Files to USB Drive [f:]
    UEFI Patch
    Start ShellHWDetection Service
    Dismount ISO
    Done ...
    
    Press any key to continue . . .

    Install Windows Setup on External drive / USB
    Code:
    "usb pe tool" 2  d:\setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso -PE
    
    Code:
    
    Stop ShellHWDetection Service
    Define Drive Letter
    Verify variables
    $$$$$ Using [d:\Setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso] as Source
    $$$$$ Mount [d:\Setup\en_windows_11_consumer_editions_version_22h2_x64_dvd.iso] to [E:]
    Check for local install
    Check User Input
    Format Usb Drive as FAT32\NADA\NTFS
    
    Index [#1] Name : Windows 11 Home
    Index [#2] Name : Windows 11 Home N
    Index [#3] Name : Windows 11 Home Single Language
    Index [#4] Name : Windows 11 Education
    Index [#5] Name : Windows 11 Education N
    Index [#6] Name : Windows 11 Pro
    Index [#7] Name : Windows 11 Pro N
    Index [#8] Name : Windows 11 Pro Education
    Index [#9] Name : Windows 11 Pro Education N
    Index [10] Name : Windows 11 Pro for Workstations
    Index [11] Name : Windows 11 Pro N for Workstations
    
    Select Edition index --> 8
    Selected Index: Windows 11 Pro Education
    Applying image 8 ("Windows 11 Pro Education") from "E:\sources\install.wim" to directory "g:\"
    Creating files: 125392 of 125392 (100%) done
    Extracting file data: 8690 MiB of 8690 MiB (100%) done
    Applying metadata to files: 125392 of 125392 (100%) done
    Done applying WIM image.
    
    $ ------------------------------------------- $
    $ Untended file location set to:              $
    $ g:\windows\Panther\AutoUnattend.xml         $
    $ ------------------------------------------- $
    
    UEFI Patch
    Start ShellHWDetection Service
    Dismount ISO
    Done ...
    
    Press any key to continue . . .
    
     

    Attached Files:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. ohenry

    ohenry MDL Senior Member

    Aug 10, 2009
    423
    252
    10
    Looks interesting, but you really need to write up some documentation. Nothing elaborate, just some example uses
     
  3. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    I Believe in self learning
    Read, understand connection, understand logic
    That how you evolve ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    now it fixed, and work as it should,
    it just took me couple days of trial & error
    but it work ….
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    Changes. (15/10/2022)
    Code:
    ~ add additional fat32 partition, to support legacy boot
      https://forums.mydigitallife.net/threads/79199/
      Update boot/EFI BCD store with new location (rpo script)
      Set legacy boot (freddie-o script)
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    #6 Dark Dinosaur, Feb 18, 2023
    Last edited: Feb 18, 2023
    (OP)
    so I made another version [SE]
    which will detect both USB / non USB devices
    it definitely un-safe, but I was needed it once
    to re-install my computer from Portable SSD PE disk
    where I wasn't able to install from -
    ISO / EXTRERNAL DISK with w10.x setup [both fails with errors]
    and I didn't have any backup …
    so I was have to figure out a solution fast
    it save my ass, so I will share it here too
     

    Attached Files:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,757
    5,221
    120
    add an helper for -pe option
    this helper will copy your $OEM$ folder content to -
    external drive where your New Windows install found

    Code:
    
    @cls
    @echo off
    >nul chcp 437
    title Copy PE tool
    setlocal enabledelayedexpansion
    
    echo:
    cd /d "%~dp0"
    
    echo:
    echo Make sure to run this script
    echo * as Administrator
    echo * as Trusted installer
    echo:
    echo Helper for "USB pe tool"
    echo with -PE Parameter
    echo:
    
    set Letter=
    set /p Letter=Enter Drive Letter:
    
    if defined Letter if exist "!Letter!:\Windows" if /i "!Letter!:" NEQ "%SystemDrive%" (
        echo:
        2>nul md "!Letter!:\windows\Panther"
        xcopy AutoUnattend.xml "!Letter!:\windows\Panther" /g /h /r /y /c /i
        echo:
        2>nul pushd "sources\$OEM$\$$" && (
            xcopy * "!Letter!:\windows" /e /g /h /r /y /c /i
            popd
        )
        echo:
        2>nul pushd "sources\$OEM$\$1" && (
            xcopy * "!Letter!:\" /e /g /h /r /y /c /i
            popd
        )
    )
    
    echo:
    pause
    goto :eof
    
     

    Attached Files:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...