windows 如何获得处理器和硬盘制造序列号和 ID?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14109168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get processor and hard disk manufacturing serial numbers and ids?
提问by Sameh Kamal
How can I get the following hardware attributes using Matlab?
如何使用 Matlab 获得以下硬件属性?
- Motherboard manufacturing serial number
- Processor Id
- Processor manufacturing serial number
- Hard disk Id
- Hard disk manufacturing serial number
- 主板制造序列号
- 处理器 ID
- 处理器制造序列号
- 硬盘 ID
- 硬盘制造序列号
And is there any function or class responsible for detecting attributes of other machine hardware components attributes?
是否有任何函数或类负责检测其他机器硬件组件属性的属性?
I know it can be done using system or console commands, but I don't know how. However, I prefer to know both two ways, the one using Windows console commands, and the one without using it.
我知道它可以使用系统或控制台命令来完成,但我不知道如何。但是,我更喜欢了解两种方式,一种使用 Windows 控制台命令,另一种不使用它。
回答by Sameh Kamal
This is a way to get hard disk serial number using console command from matlab:
这是使用 matlab 中的控制台命令获取硬盘序列号的一种方法:
%// Get hard disk serial using windows console command
cmd = 'wmic diskdrive get SerialNumber';
[~, result] = system(cmd);
%// Extract first hard disk serial number
fields = textscan( result, '%s', 'Delimiter', '\n' );
fields = strtrim(fields{1});
serialNo = fields{2};
The same for the processor id:
处理器 ID 相同:
%// Get processor id using windows console command
cmd = 'wmic cpu get ProcessorId';
[~, result] = system(cmd);
%// Extract first processor id
fields = textscan( result, '%s', 'Delimiter', '\n' );
fields = strtrim(fields{1});
processorId = fields{2};
It's all about using console command wmic
+ [hardware name]
+ get
+ [attributename]
and if you want to know the whole attributes available for some device you can use get
in your command without naming any attribute, Example:
这是所有关于使用控制台命令wmic
+ [hardware name]
+ get
+ [attributename]
,如果你想知道可用于某些设备,您可以使用全部的属性get
在你的命令不点名任何属性,例如:
command = 'wmic csproduct get'
that will get all available attributes of your machine as a product and its values.
这将获得您机器的所有可用属性作为产品及其值。
回答by Farzad Amirjavid
I can add some more commands here:
我可以在这里添加更多命令:
cmd='wmic baseboard get serialnumber';
[~, result] = system(cmd);
%// Extract first processor id
fields = textscan( result, '%s', 'Delimiter', '\n' );
fields = strtrim(fields{1});
baseboardSN = fields{2};
You can also try the following:
您还可以尝试以下操作:
wmic csproduct get name wmic bios get serialnumber wmic csproduct get UUID
wmic csproduct 获取名称 wmic bios 获取序列号 wmic csproduct 获取 UUID