@Echo off & title   Collecting information... & mode con cols=82 lines=4 & Goto [Start]
———————————————————————————————————————————————————————————————————————————————————————
 This script was created by Matthew Wai at www.TenForums.com/members/matthew-wai.html
 Modified by Ztruker at www.TenForums.com/members/ztruker.html
 The original concept was based on posts by zbook at www.TenForums.com/members/zbook.html
 Last updated by Matthew Wai on 2021-12-27.
 This script will automatically run as an administrator and then...

 Determine the number of storage devices and partitions on each device
 and create a DiskParInfo.INP file in the %Temp% folder. The INP file will contain the 
 necessary DiskPart commands for each device and partition to gather information for  
 debugging purposes.

 Run reagentc to get Windows Recovery Environment information and run bcdedit to get
 firmware Boot Manager information, also for debugging purposes.

 All output will be written into DiskParInfo.log in your %Temp% folder.
———————————————————————————————————————————————————————————————————————————————————————
:[Start]
Set "[-]=%ProgramData%\[+Get_administrative_privileges+].cmd"
(Fsutil Dirty Query %SystemDrive%>Nul)&&(Del "%[-]%" 2>Nul & Goto [Run_it])
Echo "%~f0">"%[-]%" & PowerShell start "%[-]%" -verb RunAs
If not %errorlevel%==0 (Del "%[-]%"&Exit) else (Exit /B)
:[Run_it]
Echo.&Echo    Operations are in progress. Please wait for Notepad to display the results.
Set "LOG=%ProgramData%\DiskParInfo.log"
Set "INP=%ProgramData%\DiskParInfo.inp"
Set "I=%ProgramData%\I.txt"
Set "Z=Echo     Disk %%A :" 
Set "Y=Model: %%D %%E %%F %%G %%H>>"%LOG%"" 
(Del /F /Q "%LOG%" 2>Nul) & (DEL /F /Q "%INP%" 2>Nul) & (Del /F /Q "%I%" 2>Nul)
(Echo Lis Dis & Echo Lis Vol)> "%INP%" 
(PowerShell Get-host>Nul 2>&1)||(Goto [WinPE_mode])
For /f "Skip=3 tokens=1,2,3,4,5,6,7,8" %%A in (
'"PowerShell Get-PhysicalDisk^|Select DeviceID, MediaType, BusType, FriendlyName^|Sort DeviceID"') Do (
If "%%A"=="+"		   (Goto [WinPE_mode])
If "%%B"=="Unspecified"    (set "T=%%C") else (set "T=%%B")
Call:[Check] "%%A")	
Goto [Next]

:[Check]
For /F "skip=7 tokens=*" %%# in ('"(Echo Sel Dis %~1)|DiskPart"') Do (Set "Text=%%#"
CMD /C "If "%%Text%%"=="%%Text:not valid=%%" (Echo %~1 >>"%I%" & %Z% %T%. Disk_%%A  %Y%) else (%Z% %T%. Error: It is not valid. %Y%)"
Goto:EOF)

:[Next]
For /f "tokens=*" %%# in ('"More "%I%""') Do (Cls & Set /A N+=1 
Echo.&Echo      DiskPart is getting the details of Disk %%#
Call:[Get-Partition] "%%#")
Cls&Echo.&Echo       REAgentC is getting information about Windows RE. & Goto [Final]

:[Get-Partition]
(Echo sel dis %~1 & Echo det dis & Echo lis par)>> "%INP%" & Set "A=0"
For /F "skip=12 tokens=2" %%# in ('"(Echo sel dis %~1 & Echo lis par)|DiskPart"') Do (
(Echo sel par %%# & Echo det par)>> "%INP%" & Set /A A+=1)

PowerShell (GC "%LOG%"^|%%{$_ -replace 'Disk_%~1','It has %A% partition^(s^).'})^|SC "%LOG%"
Set "A=0" 
Goto:EOF

:[Final]
(Echo.&Echo     The script has found the above %N% storage device(s^) in total.
 Echo =======================================================================)>>"%LOG%"
DiskPart /S "%INP%">> "%LOG%" & Del "%I%" 
(Echo.&Echo ===============================================================================
Echo.)>>"%LOG%" & (reagentc /info>>"%LOG%")>nul 2>&1 & Del "%INP%"
:[X]
(Echo ===============================================================================)>>"%LOG%"
bcdedit /enum all>>"%LOG%" & Move "%LOG%" "%Temp%\"
Start "" Notepad "%Temp%\DiskParInfo.log" 
Title Operations completed. & mode con cols=88 lines=11 & Echo.
Echo    ###################################################################################
Echo    #    How to capture batch file data and post in your thread in the BSOD forum     #
Echo    #                                                                                 #
Echo    #      Batch files and instructions for use in BSOD debugging [Part Two]          #
Echo    #                                                                                 #
Echo    #        Press [V] to visit the above web page for detailed instructions.         #
Echo    #        Press [C] to close this window.                                          #
Echo    ###################################################################################
Echo.
Set "[URL]=http://www.tenforums.com/bsod-crashes-debugging/162488-batch-files-use-bsod-debugging.html#Part2-1B"
CHOICE /C "VC" /M "Your choice?:" >nul 2>&1
If %errorlevel%==1 (Start "" "%[URL]%" & Exit) else (Exit)

:[WinPE_mode]
(Echo.&Echo     PowerShell Get-PhysicalDisk does not work.)>"%LOG%"
For /F "skip=9 tokens=2" %%# in ('"(Echo Lis Dis)|DiskPart"') Do (Call:[Operation_1] "%%#")
Goto [Operation_2]

:[Operation_1]
Cls&Echo.&Echo      DiskPart is getting the details of Disk %~1
(Echo sel dis %~1 & Echo det dis & Echo lis par)>> "%INP%"
For /F "skip=12 tokens=2" %%# in ('"(Echo sel dis %~1 & Echo lis par)|DiskPart"') Do (
(Echo sel par %%# & Echo det par)>> "%INP%")
Goto:EOF

:[Operation_2]
Cls&Echo.&Echo      DiskPart is writing data into the log file.
DiskPart /S "%INP%">> "%LOG%" 
(Echo.&Echo ===============================================================================
Echo.)>>"%LOG%" 
For /F "tokens=2" %%# in ('"BCDEDIT|Find "osdevice""') Do (Call:[Operation_3] "%%#")
Goto:EOF

:[Operation_3]
Cls&Echo.&Echo       REAgentC is getting information about Windows RE.
Set "[OS]=%~1"
For /f "Tokens=2* delims==" %%# in ("%[OS]%") Do (Set [OS]=%%#)
(%[OS]%\Windows\System32\Reagentc /info /Target %[OS]%\Windows>>"%LOG%")>nul 2>&1 
Goto [X]
———————————————————————————————————————————————————————————————————————————————————————