复制代码
- @echo off
- ::自动请求以管理员权限运行
- if /i "%systemdrive%"=="C:" reg query HKU\S-1-5-20>nul 2>nul || echo;CreateObject^("Shell.Application"^).ShellExecute "%~f0", "%*", "", "runas", 1 > "%temp%\getadmin.vbs" && cscript //b "%temp%\getadmin.vbs" && exit /b & del "%temp%\getadmin.vbs" /f /q>nul
- SetLocal EnableDelayedExpansion
- ::设置批处理所在目录
- set DIR_CUR=%~dp0
- cd %DIR_CUR%
- ECHO.
- ECHO 当前挂载硬盘:
- ECHO ---------------------------------------------------------
- echo.
- echo 序号 格式 协议 容量 型号 <--- 硬盘大小可不要
- echo --- --- ---- ------ --------
- ECHO 0 GPT NVME 256GB WD256
- ECHO 1 MBR SATA 1000GB WD1000
- ECHO.
- echo 序号 盘:区 大小 盘符 FS EFI/MSR 系统 标签 <--- 标签可不要
- echo --- ----- ------ --- ----- ------- ------ ------
- echo 1 0:1 500MB Z FAT32 EFI EFI
- echo 2 0:2 128MB MSR
- echo 3 0:3 100GB C NTFS WIN10 WIN
- echo 4 0:4 100GB Mac
- echo 5 0:5 37GB D exFat SHARE
- echo 6 1:1 500GB E NTFS
- echo 7 1:2 456GB F NTFS
- ECHO ---------------------------------------------------------
- echo 可根据磁盘分区编号选择,返回分区的详细信息
- echo.
- :: 保存磁盘信息
- :: set DISK_N
- :: 保存分区信息
- :: set PART_N
- for /f "skip=9 tokens=2 delims= " %%a in ('echo list disk^|diskpart') do (
- rem 下面提取硬盘信息
- for /f "delims=" %%b in ('(echo sel disk %%a ^& echo detail disk^)^|diskpart') do (
- rem 取三行,硬盘型号,id->硬盘分区格式,磁盘类型
- set "cl=%%b"
- set /a l+=1
- if "!cl:~0,5!"=="在计算机上" (set /a t=!l!+4 & set /a i=!l!+5 & set /a p=!l!+6)
- if !l!==!t! (set tt=!cl!)
- if !l!==!i! (set did=!cl:~7! & (if "!did:-=!"=="!did!" (set "ii=MBR") else (set "ii=GPT")))
- if !l!==!p! (set pp=!cl:~7! & (echo. & echo --- 硬盘:%%a !pp! !ii! !tt! ---) & set "DISK_%%a= %%a !pp! !ii! !tt!")
- )
- rem 下面遍历每个分区,并提取合并处理每个分区的信息
- for /f "tokens=2 delims= " %%c in ('(echo sel disk %%a ^& echo list part ^& exit^)^|diskpart^|findstr /i "系统 主要 未知 保留 逻辑"') do (
- set /a PARTT+=1
- :: echo 当前分区 %%a:%%c
- for /f "delims=" %%d in ('(echo sel disk %%a ^& echo list part ^& echo sel part %%c ^& echo det part^)^|diskpart') do (
- :: echo %%a:%%c 分区信息 %%d
- set "cll=%%d"
- set /a ll+=1
- if "!cll:~0,7!"==" 分区 " (
- for /f "tokens=2-5 delims= " %%e in ("!cll!") do (
- if %%c==%%e (set tinfo=%%a:%%c %%f %%g%%h)
- )
- )
- :: if "!cll:~0,2!"=="类型" (echo !cll:~6! 提取对照生成准确文件系统)
- if "!cll:~0,4!"=="字节偏移" (set /a lll=!ll!+3 & set /a kkk=!ll!+2)
- if !ll!==!lll! (if "!cll:~0,1!"=="*" (echo !PARTT! !tinfo! !cll:~13,23!))
- if !ll!==!kkk! (if "!cll:~0,1!"=="D" (echo !PARTT! !tinfo!))
- )
- )
- )
- echo.
- pause>nul
复制代码
- (rem 设置分区ID,用于文件系统辅助识别
- set "$01=FAT12"
- set "$02=Xenix /"
- set "$03=Xenix /usr"
- set "$04=FAT16 <32M"
- set "$05=Extended"
- set "$06=FAT16 >=32M"
- set "$07=HPFS/NTFS/exFAT"
- set "$08=AIX"
- set "$09=AIX Boot"
- set "$0A=OS/2 Boot"
- set "$0B=FAT32"
- set "$0C=FAT32 LBA"
- set "$0E=FAT16 LBA"
- set "$0F=Extended LBA"
- set "$10=OPUS"
- set "$11=Hidden FAT12"
- set "$12=Compaq Diagnostics"
- set "$14=Hidden FAT16 <32M"
- set "$16=Hidden FAT16 >=32M"
- set "$17=Hidden HPFS/NTFS"
- set "$18=AST Swap"
- set "$1B=Hidden FAT32"
- set "$1C=Hidden FAT32 LBA"
- set "$1E=Hidden FAT16 LBA"
- set "$24=NEC DOS"
- set "$27=Microsoft Recovery Partition"
- set "$35=OS/2 JFS"
- set "$38=THE OS V3 2gb"
- set "$39=THE OS V4 spanned"
- set "$3A=THE OS V4 4gb"
- set "$3B=THE OS V4 extended"
- set "$3C=PartitionMagic recovery"
- set "$3D=Novell Netware(Hidden)"
- set "$40=VENIX 286"
- set "$41=Linux/MINIX (sharing with DRDOS)"
- set "$42=RAID"
- set "$43=Linux native (sharing with DRDOS)"
- set "$45=Boot-US"
- set "$4C=Oberon"
- set "$4D=QNX 4.2 Primay"
- set "$4E=QNX 4.2 Secondary"
- set "$4F=QNX 4.2 Tertiary"
- set "$50=DM (DIsk Danager)"
- set "$51=Novell(or DM6 Aux1)"
- set "$52=CP/M or Microport SysV/AT"
- set "$53=DM6 Aux3"
- set "$54=DM6"
- set "$55=ES-Drive (Disk Manager)"
- set "$56=Golded Bow (Disk Manager)"
- set "$57=DrivePro"
- set "$5C=Priam Edisk (Disk Manager)"
- set "$61=SpeedStor"
- set "$63=UNIX, System V/386, GNU HURD or Mach"
- set "$64=Novell Netware/286 2.xx"
- set "$65=Novell Netware/386 3.xx"
- set "$66=Novell"
- set "$67=Novell"
- set "$68=Novell"
- set "$69=Novell"
- set "$70=DiskSecure Multi-Boot"
- set "$74=Scramdisk"
- set "$75=PC/IX"
- set "$77=QNX4.x"
- set "$78=QNX4.x 2nd part"
- set "$79=QNX4.x 3rd part"
- set "$80=Minix util 1.4a"
- set "$81=Early Linux, or Minix since 1.4b"
- set "$82=Linux Swap"
- set "$83=Linux Native, or Ext2/3/4 (Linux Data)"
- set "$85=Linux extended"
- set "$86=FAT16 volume"
- set "$87=NTFS volume"
- set "$8B=FAT32 volume"
- set "$8C=FAT32 LBA volume"
- set "$93=Amoeba"
- set "$94=Amoeba bad block table"
- set "$9F=BSD/OS"
- set "$A0=Hibernation"
- set "$A1=Hibernation"
- set "$A5=FreeBSD/NetBSD"
- set "$A6=OpenBSD"
- set "$A7=NextStep"
- set "$A9=NetBSD"
- set "$AA=Olivetti FAT12"
- set "$AC=IBM JFS"
- set "$B7=BSDI BSD/386"
- set "$B8=BSDI BSD/386 Swap"
- set "$BE=Solaris boot"
- set "$C0=DR-DOS"
- set "$C1=DRDOS/sec FAT12"
- set "$C4=DRDOS/sec FAT16"
- set "$C6=Corrupted FAT16"
- set "$C7=Corrupted NTFS"
- set "$D8=CP/M-86"
- set "$DB=CP/M, Concurrent DOS or CTOS"
- set "$DF=BootIt"
- set "$E1=DOS access FAT12"
- set "$E3=DOS R/O or SpeedStor"
- set "$E4=SpeedStor FAT16"
- set "$EB=BeOS"
- set "$EE=Protected MBR"
- set "$EF=EFI System Partition"
- set "$F1=SpeedStor"
- set "$F2=DOS 3.3+ Secondary"
- set "$F4=SpeedStor Large"
- set "$FB=VMware VMFS"
- set "$FC=VMware Swap"
- set "$FD=Linux RAID"
- set "$FE=SpeedStor"
- set "$FF=XENIX bad blocks table"
- rem 设置GPT标识符,数据来自英文维基百科,不保证正确,仅供参考
- set "$00000000-0000-0000-0000-000000000000=未使用"
- set "$024DEE41-33E7-11D3-9D69-0008C781F39F=MBR分区表"
- set "$C12A7328-F81F-11D2-BA4B-00A0C93EC93B=ESP"
- set "$21686148-6449-6E6F-744E-656564454649=BIOS引导分区"
- set "$D3BFE2DE-3DAF-11DF-BA40-E3A556D89593=iFFS分区(Intel快速启动)"
- set "$F4019732-066E-4E12-8273-346C5641494F=Sony引导分区"
- set "$BFBFAFE7-A34F-448A-9A5B-6213EB736C22=Lenovo引导分区"
- set "$E3C9E316-0B5C-4DB8-817D-F92DF00215AE=MSR"
- set "$EBD0A0A2-B9E5-4433-87C0-68B6B72699C7=基本数据分区"
- set "$5808C8AA-7E8F-42E0-85D2-E1E90434CFB3=LDM元数据分区"
- set "$AF9B60A0-1431-4F62-BC68-3311714A69AD=LDM数据分区"
- set "$DE94BBA4-06D1-4D40-A16A-BFD50179D6AC=WinRE"
- set "$37AFFC90-EF7D-4E96-91C3-2D7AE055B174=IBM GPFS分区"
- set "$E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D=存储空间分区"
- set "$75894C1E-3AEB-11D3-B7C1-7B03A0000000=HP-UX 数据分区"
- set "$E2A1E728-32E3-11D6-A682-7B03A0000000=HP-UX 服务分区"
- set "$0FC63DAF-8483-4772-8E79-3D69D8477DE4=Linux 文件系统数据"
- set "$A19D880F-05FC-4D3B-A006-743F0F84911E=Linux RAID 分区"
- set "$44479540-F297-41B2-9AF7-D131D5F0458A=Linux / (x86)"
- set "$4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709=Linux / (x86-64)"
- set "$69DAD710-2CE4-4E3C-B16C-21A1D49ABED3=Linux / (32-bit ARM)"
- set "$B921B045-1DF0-41C3-AF44-4C6F280D3FAE=Linux / (64-bit ARM/AArch64)"
- set "$0657FD6D-A4AB-43C4-84E5-0933C84B4F4F=Linux 交换分区"
- set "$E6D6D379-F507-44C2-A23C-238F2A3DF928=Linux 逻辑卷管理器(LVM)分区"
- set "$933AC7E1-2EB4-4F13-B844-0E14E2AEF915=Linux /home"
- set "$3B8F8425-20E0-4F3B-907F-1A25A76F98E8=Linux /srv"
- set "$7FFEC5C9-2D00-49B7-8941-3EA10A5586B7=Linux 普通dm-crypt分区"
- set "$CA7D7CCB-63ED-4C53-861C-1742536059CC=Linux LUKS分区"
- set "$8DA63339-0007-60C0-C436-083AC8230908=Linux 保留"
- set "$83BD6B9D-7F41-11DC-BE0B-001560B84F0F=FreeBSD 启动分区"
- set "$516E7CB4-6ECF-11D6-8FF8-00022D09712B=FreeBSD 数据分区"
- set "$516E7CB5-6ECF-11D6-8FF8-00022D09712B=FreeBSD 交换分区"
- set "$516E7CB6-6ECF-11D6-8FF8-00022D09712B=FreeBSD UFS分区"
- set "$516E7CB8-6ECF-11D6-8FF8-00022D09712B=FreeBSD Vinum 卷管理器分区"
- set "$516E7CBA-6ECF-11D6-8FF8-00022D09712B=FreeBSD ZFS分区"
- set "$48465300-0000-11AA-AA11-00306543ECAC=Mac OS X HFS+分区"
- set "$7C3457EF-0000-11AA-AA11-00306543ECAC=Mac OS X Apple APFS"
- set "$55465300-0000-11AA-AA11-00306543ECAC=Mac OS X Apple UFS container"
- set "$6A898CC3-1DD2-11B2-99A6-080020736631=Mac OS X ZFS"
- set "$52414944-0000-11AA-AA11-00306543ECAC=Mac OS X Apple RAID分区"
- set "$52414944-5F4F-11AA-AA11-00306543ECAC=Mac OS X Apple RAID分区,离线"
- set "$426F6F74-0000-11AA-AA11-00306543ECAC=Mac OS X Apple引导分区(恢复HD)"
- set "$4C616265-6C00-11AA-AA11-00306543ECAC=Mac OS X Apple Label"
- set "$5265636F-7665-11AA-AA11-00306543ECAC=Mac OS X Apple TV恢复分区"
- set "$53746F72-6167-11AA-AA11-00306543ECAC=Mac OS X Apple 核心存储分区 "
- set "$B6FA30DA-92D2-4A9A-96F1-871EC6486200=Mac OS X SoftRAID_Status"
- set "$2E313465-19B9-463F-8126-8A7993773801=Mac OS X SoftRAID_Scratch"
- set "$FA709C7E-65B1-4593-BFD5-E71D61DE9B02=Mac OS X SoftRAID_Volume"
- set "$BBBA6DF5-F46F-4A89-8F59-8765B2727503=Mac OS X SoftRAID_Cache"
- set "$6A82CB45-1DD2-11B2-99A6-080020736631=Solaris illumos启动分区"
- set "$6A85CF4D-1DD2-11B2-99A6-080020736631=Solaris /"
- set "$6A87C46F-1DD2-11B2-99A6-080020736631=Solaris 交换分区"
- set "$6A8B642B-1DD2-11B2-99A6-080020736631=Solaris 备份分区"
- set "$6A898CC3-1DD2-11B2-99A6-080020736631=Solaris /usr"
- set "$6A8EF2E9-1DD2-11B2-99A6-080020736631=Solaris /var"
- set "$6A90BA39-1DD2-11B2-99A6-080020736631=Solaris /home"
- set "$6A9283A5-1DD2-11B2-99A6-080020736631=Solaris 备用扇区"
- set "$6A945A3B-1DD2-11B2-99A6-080020736631=Solaris 保留分区"
- set "$6A9630D1-1DD2-11B2-99A6-080020736631=Solaris 保留分区"
- set "$6A980767-1DD2-11B2-99A6-080020736631=Solaris 保留分区"
- set "$6A96237F-1DD2-11B2-99A6-080020736631=Solaris 保留分区"
- set "$6A8D2AC7-1DD2-11B2-99A6-080020736631=Solaris 保留分区"
- set "$49F48D32-B10E-11DC-B99B-0019D1879648=NetBSD 交换分区"
- set "$49F48D5A-B10E-11DC-B99B-0019D1879648=NetBSD FFS分区"
- set "$49F48D82-B10E-11DC-B99B-0019D1879648=NetBSD LFS分区"
- set "$49F48DAA-B10E-11DC-B99B-0019D1879648=NetBSD RAID分区"
- set "$2DB519C4-B10F-11DC-B99B-0019D1879648=NetBSD 串联分区"
- set "$2DB519EC-B10F-11DC-B99B-0019D1879648=NetBSD 加密分区"
- set "$FE3A2A5D-4F32-41A7-B725-ACCC3285A309=Chrome OS 内核"
- set "$3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC=Chrome OS 根文件系统"
- set "$2E0A753D-9E48-43B0-8337-B15192CB1B5E=Chrome OS 未来用途"
- set "$42465331-3BA3-10F1-802A-4861696B7521=Haiku BFS"
- set "$85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7=MidnightBSD 启动分区"
- set "$85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7=MidnightBSD 数据分区"
- set "$85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7=MidnightBSD 交换分区"
- set "$0394EF8B-237E-11E1-B4B3-E89A8F7FC3A7=MidnightBSD UFS分区"
- set "$85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7=MidnightBSD Vinum 卷管理器分区"
- set "$85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7=MidnightBSD ZFS分区"
- set "$824CC7A0-36A8-11E3-890A-952519AD3F61=OpenBSD 数据分区"
- set "$CEF5A9AD-73BC-4601-89F3-CDEEEEE321A1=QNX Power-safe (QNX6) 文件系统"
- set "$C91818F9-8025-47AF-89D2-F030D7000C2C=Plan 9 分区"
- set "$9D275380-40AD-11DB-BF97-000C2911D1B8=VMware ESX vmkcore (核心转储分区)"
- set "$AA31E02A-400F-11DB-9590-000C2911D1B8=VMware ESX VMFS文件系统分区"
- set "$9198EFFC-31C0-11DB-8F78-000C2911D1B8=VMware ESX VMware 保留"
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |