DiskParInfo.bat to work in WinPE environment of Windows 11 boot media and in Live OS


Ramesh Sharma

Well-known member
Member
Local time
6:21 AM
Posts
292
OS
Window 11 v24H2 Build 26100.2033
Hello everyone,

With reference to this link: Batch files for use in BSOD debugging - Windows 10 Help Forums

With the help of Gemini AI, I have modified the batch file DiskParInfo.bat to work in the WinPE environment of Windows 11 boot media as well as in a Live OS from a Command Prompt run as administrator.

This is to identify each external and internal HDD/SSD attached to the PC/laptop, along with all partitions on each drive.

1. Just place DiskParInfo.bat in the root of the FAT32 partition of your Windows 11 boot media. Boot from this boot drive and press Shift+F10 at the first screen to open the Command Prompt.
2. Run Diskpart from the Command Prompt to find the drive letter of the boot drive's FAT32 partition. Then run DiskParInfo.bat using that USB boot drive letter.
3. If the code for DiskParInfo.bat is opened in Notepad, please save the file in ANSI encoding with "All Files" selected. I have attached the batch file below. The log files (from WinPE Environment and from Live OS) show all partitions of each internal and external drive attached to my laptop.

Thanks TenForums.
Thanks Gemini AI.
Thanks everyone.

Code:
@Echo off
Title Collecting Disk and Boot Information...
Setlocal EnableExtensions EnableDelayedExpansion

Set "LOG=%TEMP%\DiskParInfo.log"
Set "INP=%TEMP%\DiskParInfo.inp"
Set "SCR=%TEMP%\dp_cmd.txt"
Set "OUT=%TEMP%\dp_out.txt"
Set "SUMMARY=%TEMP%\dp_summary.txt"

Del /F /Q "%LOG%" >nul 2>&1
Del /F /Q "%INP%" >nul 2>&1
Del /F /Q "%SCR%" >nul 2>&1
Del /F /Q "%OUT%" >nul 2>&1
Del /F /Q "%SUMMARY%" >nul 2>&1

Set /A TotalDisks=0

:: Preload basic disk/volume commands
>"%INP%" Echo lis dis
>>"%INP%" Echo lis vol

:: Parse disks safely via list disk
>"%SCR%" Echo lis dis
diskpart /s "%SCR%" > "%OUT%" 2>nul

For /F "tokens=1,2" %%A in ('Type "%OUT%"') Do (
    If /I "%%A"=="Disk" (
        Set "CheckNum=%%B"
        For /F "delims=0123456789" %%C in ("!CheckNum!") Do Set "CheckNum="
        If defined CheckNum (
            Set /A TotalDisks+=1
            Call :InspectDisk "%%B"
        )
    )
)
Del "%SCR%" >nul 2>&1
Del "%OUT%" >nul 2>&1

:: Assemble log beginning with summary block
>"%LOG%" Echo.
If Exist "%SUMMARY%" >>"%LOG%" Type "%SUMMARY%"
>>"%LOG%" Echo.
>>"%LOG%" Echo     The script has found the above !TotalDisks! storage device(s^) in total.
>>"%LOG%" Echo ===============================================================================
Del "%SUMMARY%" >nul 2>&1

Cls
Echo.
Echo Processing disk layout and details...
DiskPart /S "%INP%" >> "%LOG%"
Del "%INP%" >nul 2>&1

>>"%LOG%" Echo.
>>"%LOG%" Echo ===============================================================================
>>"%LOG%" Echo.

:: Check Recovery Environment across all assigned drives
Set "REAGENTC_EXE="
If Exist "%SystemRoot%\System32\reagentc.exe" Set "REAGENTC_EXE=%SystemRoot%\System32\reagentc.exe"

Set "FOUND_TARGET="
For %%D in (C 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:\Windows\System32\cmd.exe" (
        Set "FOUND_TARGET=1"
        If defined REAGENTC_EXE (
            "%REAGENTC_EXE%" /info /target "%%D:\Windows" >> "%LOG%" 2>&1
        ) Else If Exist "%%D:\Windows\System32\reagentc.exe" (
            "%%D:\Windows\System32\reagentc.exe" /info /target "%%D:\Windows" >> "%LOG%" 2>&1
        ) Else (
            >>"%LOG%" Echo Windows RE information unavailable (reagentc not present in WinPE^).
        )
    )
)

If not defined FOUND_TARGET (
    If defined REAGENTC_EXE "%REAGENTC_EXE%" /info >> "%LOG%" 2>&1
)

>>"%LOG%" Echo.
>>"%LOG%" Echo ===============================================================================
>>"%LOG%" Echo.

:: BCD Store Retrieval: Handle multiple EFI partitions in WinPE
Set "BCDDONE="
bcdedit /enum all >> "%LOG%" 2>&1
If %errorlevel%==0 Set "BCDDONE=1"

If not defined BCDDONE (
    >>"%LOG%" Echo Multiple system partitions detected. Querying EFI store directly...
    >"%SCR%" Echo sel dis 0
    >>"%SCR%" Echo sel par 1
    >>"%SCR%" Echo assign letter=S
diskpart /s "%SCR%" >nul 2>&1

    If Exist "S:\EFI\Microsoft\Boot\BCD" (
        bcdedit /store S:\EFI\Microsoft\Boot\BCD /enum all >> "%LOG%" 2>&1
    )

    >"%SCR%" Echo sel dis 0
    >>"%SCR%" Echo sel par 1
    >>"%SCR%" Echo remove letter=S
    diskpart /s "%SCR%" >nul 2>&1
    Del "%SCR%" >nul 2>&1
)

:: Display output on screen
Cls
Type "%LOG%"
Echo.
Echo ===============================================================================
Echo Output saved to: %LOG%
Echo ===============================================================================
Echo.

:: Open in Notepad if available in WinPE image or script directory
If Exist "%SystemRoot%\System32\notepad.exe" (
    Start "" notepad "%LOG%"
) Else If Exist "%~dp0notepad.exe" (
    Start "" "%~dp0notepad.exe" "%LOG%"
)

Pause
Exit /B

:InspectDisk
Set "DN=%~1"
Set "DModel="
Set "DType=HDD"
Set /A PCount=0
Set "CaptureModel="

:: Explicit redirection syntax prevents file descriptor conflicts (0>, 1>, 2>)
>"%SCR%" Echo sel dis %DN%
>>"%SCR%" Echo det dis
>>"%SCR%" Echo lis par
diskpart /s "%SCR%" > "%OUT%" 2>nul

For /F "usebackq tokens=*" %%L in ("%OUT%") Do (
    Set "Line=%%L"
 
    If "!Line!"=="Disk %DN% is now the selected disk." (
        Set "CaptureModel=1"
    ) Else If defined CaptureModel (
        If not defined DModel (
            If not "!Line:~0,8!"=="Disk ID:" (
                If not "!Line:~0,4!"=="Type" (
                    Set "DModel=!Line!"
                    Set "CaptureModel="
                )
            )
        )
    )

    If "!Line:~0,4!"=="Type" (
        Set "BusLine=!Line!"
        If not "!BusLine:USB=!"=="!BusLine!" Set "DType=USB"
    )

    For /F "tokens=1,2" %%A in ("!Line!") Do (
        If /I "%%A"=="Partition" (
            Set "PNum=%%B"
            For /F "delims=0123456789" %%C in ("!PNum!") Do Set "PNum="
            If defined PNum Set /A PCount+=1
        )
    )
)

If not defined DModel Set "DModel=Disk %DN%"

:: Distinguish SSD vs HDD vs USB Flash
If not "!DModel:SSD=!"=="!DModel!" Set "DType=SSD"
If not "!DModel:NVMe=!"=="!DModel!" Set "DType=SSD"
If not "!DModel:W800S=!"=="!DModel!" Set "DType=SSD"
If not "!DModel:ST1000=!"=="!DModel!" Set "DType=HDD"
If not "!DModel:Seagate=!"=="!DModel!" Set "DType=HDD"
If not "!DModel:Kingster=!"=="!DModel!" Set "DType=HDD"

>>"%SUMMARY%" Echo     Disk %DN% : !DType!. It has !PCount! partition(s^). Model: !DModel!

:: Queue detail and partition commands to INP
>>"%INP%" Echo sel dis %DN%
>>"%INP%" Echo det dis
>>"%INP%" Echo lis par

For /F "usebackq tokens=1,2" %%A in ("%OUT%") Do (
    If /I "%%A"=="Partition" (
        Set "PNum=%%B"
        For /F "delims=0123456789" %%C in ("!PNum!") Do Set "PNum="
        If defined PNum (
            >>"%INP%" Echo sel dis %DN%
            >>"%INP%" Echo sel par %%B
            >>"%INP%" Echo det par
        )
    )
)
Goto :EOF

Code:
    Disk 0 : SSD. It has 4 partition(s). Model: W800S 128GB
    Disk 1 : HDD. It has 7 partition(s). Model: ST1000LM  SCSI Disk Device
    Disk 2 : USB. It has 1 partition(s). Model: Generic MassStorageClass USB Device
    Disk 3 : USB. It has 1 partition(s). Model: Kingston DataTraveler 3.0 USB Device

    The script has found the above 4 storage device(s) in total.
===============================================================================

Microsoft DiskPart version 10.0.22000.1

Copyright (C) Microsoft Corporation.
On computer: MINWINPC

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          119 GB  2048 KB        *
  Disk 1    Online          931 GB  5120 KB        *
  Disk 2    Online          119 GB    87 GB
  Disk 3    Online           28 GB      0 B

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows 10   NTFS   Partition     64 GB  Healthy
  Volume 1     D   Windows 11   NTFS   Partition     55 GB  Healthy
  Volume 2                      FAT32  Partition    100 MB  Healthy    Hidden
  Volume 3     E   Windows_25H  NTFS   Partition    243 GB  Healthy
  Volume 4     F   DATA BACKUP  NTFS   Partition    585 GB  Healthy
  Volume 5     G   RECOVERY PA  NTFS   Partition     90 GB  Healthy
  Volume 6     H   4DDIG        FAT32  Partition     10 GB  Healthy
  Volume 7         SYSTEM       FAT32  Partition    500 MB  Healthy    Hidden
  Volume 8                      NTFS   Partition    820 MB  Healthy    Hidden
  Volume 9     I   ESD-USB      FAT32  Removable     32 GB  Healthy
  Volume 10    J   CCCOMA_X64F  NTFS   Removable     28 GB  Healthy

Disk 0 is now the selected disk.

W800S 128GB
Disk ID: {EF433D3C-FB65-4E67-A289-97CA2BB4601D}
Type   : SATA
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1200)#ATA(C00T00L00)
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows 10   NTFS   Partition     64 GB  Healthy
  Volume 1     D   Windows 11   NTFS   Partition     55 GB  Healthy
  Volume 2                      FAT32  Partition    100 MB  Healthy    Hidden

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             100 MB  1024 KB
  Partition 2    Reserved            16 MB   101 MB
  Partition 3    Primary             64 GB   117 MB
  Partition 4    Primary             55 GB    64 GB

Disk 0 is now the selected disk.

Partition 1 is now the selected partition.

Partition 1
Type    : c12a7328-f81f-11d2-ba4b-00a0c93ec93b
Hidden  : Yes
Required: No
Attrib  : 0X8000000000000000
Offset in Bytes: 1048576

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 2                      FAT32  Partition    100 MB  Healthy    Hidden

Disk 0 is now the selected disk.

Partition 2 is now the selected partition.

Partition 2
Type    : e3c9e316-0b5c-4db8-817d-f92df00215ae
Hidden  : Yes
Required: No
Attrib  : 0X8000000000000000
Offset in Bytes: 105906176

There is no volume associated with this partition.

Disk 0 is now the selected disk.

Partition 3 is now the selected partition.

Partition 3
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 122683392

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 0     C   Windows 10   NTFS   Partition     64 GB  Healthy

Disk 0 is now the selected disk.

Partition 4 is now the selected partition.

Partition 4
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: Yes
Attrib  : 0X0000000000000001
Offset in Bytes: 68866764800

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 11    D   Windows 11   NTFS   Partition     55 GB  Healthy    Hidden

Disk 1 is now the selected disk.

ST1000LM  SCSI Disk Device
Disk ID: {AD0E037F-CB03-4522-87C9-517E400CBD18}
Type   : USB
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : UNAVAILABLE
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 3     E   Windows_25H  NTFS   Partition    243 GB  Healthy
  Volume 4     F   DATA BACKUP  NTFS   Partition    585 GB  Healthy
  Volume 5     G   RECOVERY PA  NTFS   Partition     90 GB  Healthy
  Volume 6     H   4DDIG        FAT32  Partition     10 GB  Healthy
  Volume 7         SYSTEM       FAT32  Partition    500 MB  Healthy    Hidden
  Volume 8                      NTFS   Partition    820 MB  Healthy    Hidden

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Reserved            15 MB    17 KB
  Partition 2    System             500 MB    16 MB
  Partition 3    Primary            243 GB   516 MB
  Partition 4    Recovery           820 MB   243 GB
  Partition 5    Primary            585 GB   244 GB
  Partition 6    Primary             90 GB   830 GB
  Partition 7    Primary             10 GB   921 GB

Disk 1 is now the selected disk.

Partition 1 is now the selected partition.

Partition 1
Type    : e3c9e316-0b5c-4db8-817d-f92df00215ae
Hidden  : Yes
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 17408

There is no volume associated with this partition.

Disk 1 is now the selected disk.

Partition 2 is now the selected partition.

Partition 2
Type    : c12a7328-f81f-11d2-ba4b-00a0c93ec93b
Hidden  : Yes
Required: No
Attrib  : 0X8000000000000000
Offset in Bytes: 16777216

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 7         SYSTEM       FAT32  Partition    500 MB  Healthy    Hidden

Disk 1 is now the selected disk.

Partition 3 is now the selected partition.

Partition 3
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 541065216

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 3     E   Windows_25H  NTFS   Partition    243 GB  Healthy

Disk 1 is now the selected disk.

Partition 4 is now the selected partition.

Partition 4
Type    : de94bba4-06d1-4d40-a16a-bfd50179d6ac
Hidden  : Yes
Required: Yes
Attrib  : 0X8000000000000001
Offset in Bytes: 261824184320

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 8                      NTFS   Partition    820 MB  Healthy    Hidden

Disk 1 is now the selected disk.

Partition 5 is now the selected partition.

Partition 5
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 262685065216

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 4     F   DATA BACKUP  NTFS   Partition    585 GB  Healthy

Disk 1 is now the selected disk.

Partition 6 is now the selected partition.

Partition 6
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 891830665216

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 5     G   RECOVERY PA  NTFS   Partition     90 GB  Healthy

Disk 1 is now the selected disk.

Partition 7 is now the selected partition.

Partition 7
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 988964454400

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 6     H   4DDIG        FAT32  Partition     10 GB  Healthy

Disk 2 is now the selected disk.

Generic MassStorageClass USB Device
Disk ID: 0C7CFFA2
Type   : USB
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : UNAVAILABLE
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 9     I   ESD-USB      FAT32  Removable     32 GB  Healthy

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary             32 GB  1024 KB

Disk 2 is now the selected disk.

Partition 1 is now the selected partition.

Partition 1
Type  : 0C
Hidden: No
Active: Yes
Offset in Bytes: 1048576

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 9     I   ESD-USB      FAT32  Removable     32 GB  Healthy

Disk 3 is now the selected disk.

Kingston DataTraveler 3.0 USB Device
Disk ID: 0038CF65
Type   : USB
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : UNAVAILABLE
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 10    J   CCCOMA_X64F  NTFS   Removable     28 GB  Healthy

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary             28 GB  1024 KB

Disk 3 is now the selected disk.

Partition 1 is now the selected partition.

Partition 1
Type  : 07
Hidden: No
Active: Yes
Offset in Bytes: 1048576

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 10    J   CCCOMA_X64F  NTFS   Removable     28 GB  Healthy

===============================================================================

Windows Recovery Environment (Windows RE) and system reset configuration
Information:

    Windows RE status:         Disabled
    Windows RE location:
    Boot Configuration Data (BCD) identifier: fafe782e-0cad-11f1-97a9-abdc42142a72
    Recovery image location:
    Recovery image index:      0
    Custom image location:
    Custom image index:        0

REAGENTC.EXE: Operation Successful.
 
Windows Recovery Environment (Windows RE) and system reset configuration
Information:

    Windows RE status:         Disabled
    Windows RE location:
    Boot Configuration Data (BCD) identifier: 230a912c-5c49-11f1-8f40-8bfddc8ab84c
    Recovery image location:
    Recovery image index:      0
    Custom image location:
    Custom image index:        0
    Windows RE Version:        0.0.0.0

REAGENTC.EXE: Operation Successful.
 
Windows Recovery Environment (Windows RE) and system reset configuration
Information:

    Windows RE status:         Disabled
    Windows RE location:
    Boot Configuration Data (BCD) identifier: d7b9cc9a-9bef-11f1-9088-c173913154bc
    Recovery image location:
    Recovery image index:      0
    Custom image location:
    Custom image index:        0
    Windows RE Version:        0.0.0.0

REAGENTC.EXE: Operation Successful.
 

===============================================================================

The boot configuration data store could not be opened.
The requested system device cannot be identified due to m
 
Windows Build/Version
Edition Windows 11 Home Single Language Version 25H2 OS build 26200.9445

Attachments

Last edited:

My Computer My Computer

At a glance

Window 11 v24H2 Build 26100.2033Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz 3.10 GHz4.00 GB (3.89 GB usable)Onboard
OS
Window 11 v24H2 Build 26100.2033
Computer type
PC/Desktop
Manufacturer/Model
ASSEMMBLED
CPU
Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz 3.10 GHz
Motherboard
ZEBRONICS
Memory
4.00 GB (3.89 GB usable)
Graphics Card(s)
Onboard
Sound Card
Onboard
Monitor(s) Displays
LG
Screen Resolution
1366x768
Hard Drives
Toshiba HDD 1 TB
Keyboard
Mechanical
Mouse
Mechanical
Internet Speed
700 kb/s
Browser
Microsoft EDGE, CHROME
Antivirus
Microsoft Defender
I don't see any use for this batch script.
 

My Computer My Computer

At a glance

Windows 11AMD Ryzen 7 5700GMicron Technology DDR4-3200 16GBNVIDIA GeForce RTX 3060
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
HP Pavilion
CPU
AMD Ryzen 7 5700G
Motherboard
Erica6
Memory
Micron Technology DDR4-3200 16GB
Graphics Card(s)
NVIDIA GeForce RTX 3060
Sound Card
Realtek ALC671
Monitor(s) Displays
Samsung SyncMaster U28E590
Screen Resolution
3840 x 2160
Hard Drives
SAMSUNG MZVLQ1T0HALB-000H1
Back
Top Bottom