可启动设备的序列号 [英] Serial Number of Bootable device
本文介绍了可启动设备的序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须获得安装我的操作系统的磁盘的序列号.
I have to get the serialnumber of the disk on which my operating system is installed.
我知道为了获得序列号我需要运行:
I know in order to get serial number i need to run:
>wmic diskdrive get serialnumber,capabilities
Capabilities SerialNumber
{3, 4} AI92NXXXXXXXX2G02
{3, 4, 7} 1172XXXXXX030
没有用于检查操作系统是否安装在此磁盘上的属性.
There are no attributes to check if the OS is installed on this disk.
推荐答案
开始使用 wmic partition where Bootable=True
然后回溯到 Win32_DiskDrive
(一种可能的方法):
Start using wmic partition where Bootable=True
and then backtrack to Win32_DiskDrive
(a possible approach):
@ECHO OFF
SETLOCAL EnableExtensions DisableDelayedExpansion
for /F "delims=" %%G in ('
wmic path Win32_DiskPartition where "Bootable=True" get DeviceID /Value
') do (
for /F "tokens=1* delims==" %%g in ("%%G") do (
set "_DiskPartition=%%h"
REM ECHO set "_DiskPartition=%%h"
call :GetDiskDriveIdAndOutput
)
)
echo Possibly no linkage to a logical disk:
2>NUL wmic path Win32_LogicalDisk ^
ASSOC /RESULTROLE:Antecedent ^
/ASSOCCLASS:Win32_LogicalDiskToPartition ^
/RESULTCLASS:Win32_DiskPartition
ENDLOCAL
goto :eof
:GetDiskDriveIdAndOutput
for /F tokens^=^2^ delims^=^" %%B in ('
wmic path Win32_DiskPartition where "Bootable=True" ASSOC /ASSOCCLASS:Win32_DiskDriveToDiskPartition
') do (
if NOT "%%B"=="%_DiskPartition%" (
REM ECHO set "_DiskDriveId=%%B"
set "_DiskDriveId=%%B"
)
)
echo Bootable: Drive = "%_DiskDriveId:\\=\%", Partition = "%_DiskPartition%"
wmic path Win32_DiskDrive get Capabilities,DeviceId,SerialNumber
REM wmic path Win32_DiskDrive Where "DeviceId='%_DiskDriveId%'" get Capabilities,DeviceId,SerialNumber
goto :eof
当然,它可以从实际输出
Bootable: Drive = "\\.\PHYSICALDRIVE0", Partition = "Disk #0, Partition #0"
Capabilities DeviceID SerialNumber
{3, 4} \\.\PHYSICALDRIVE0 NXXXXXXXXK4R2DT
{3, 4, 7} \\.\PHYSICALDRIVE1 S0NFJNXXXXXXXX
类似的东西
Capabilities DeviceID SerialNumber Bootable
{3, 4} \\.\PHYSICALDRIVE0 NXXXXXXXXK4R2DT True
{3, 4, 7} \\.\PHYSICALDRIVE1 S0NFJNXXXXXXXX
这篇关于可启动设备的序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文