如何获得处理器和硬盘制造商的序列号和ID? [英] How can I get processor and hard disk manufacturing serial numbers and ids?
问题描述
如何使用Matlab获得以下硬件属性?
How can I get the following hardware attributes using Matlab?
- 主板制造序列号
- 处理器ID
- 处理器制造序列号
- 硬盘ID
- 硬盘制造序列号
是否有任何函数或类负责检测其他机器硬件组件的属性?
And is there any function or class responsible for detecting attributes of other machine hardware components attributes?
我知道可以使用系统或控制台命令来完成,但是我不知道如何做.但是,我更喜欢两种方法,一种是使用Windows控制台命令,另一种是不使用它.
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.
推荐答案
这是一种使用Matlab控制台命令获取硬盘序列号的方法:
This is a way to get hard disk serial number using console command from 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};
处理器ID相同:
The same for the processor 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};
所有有关使用控制台命令wmic
+ [hardware name]
+ get
+ [attributename]
如果您想了解某些设备可用的全部属性,可以在命令中使用get
而不命名任何属性,例如:
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:
command = 'wmic csproduct get'
这将获得您的机器作为产品及其值的所有可用属性.
that will get all available attributes of your machine as a product and its values.
这篇关于如何获得处理器和硬盘制造商的序列号和ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!