好记性不如铅笔头

windows, 技巧, 操作系统

wmic最简单使用

wmic是一个非常强大的命令工具,可以非常方便快捷的查询本地Windows的一些信息。这里简单笔记下如何使用,后续具体使用可以在网上查找对应的资料:

交互式使用,可以先看下都支持哪些命令。

C:\Users\cstriker1407>wmic #进入交互式命令
wmic:root\cli>
"/?" for help, QUIT to Exit.
wmic:root\cli>/? #查看都有哪些命令可以使用

[global switches] <command>

The following global switches are available:
/NAMESPACE           Path for the namespace the alias operate against.
/ROLE                Path for the role containing the alias definitions.
。。。。。。
。。。。。。
/AUTHORITY           Specifies the <authority type> for the connection.
/?[:<BRIEF|FULL>]    Usage information.

For more information on a specific global switch, type: switch-name /?


The following alias/es are available in the current role:
ALIAS                    - Access to the aliases available on the local system
BASEBOARD                - Base board (also known as a motherboard or system board) management.
。。。。。。
。。。。。。
USERACCOUNT              - User account management.
VOLTAGE                  - Voltage sensor (electronic voltmeter) data management.
VOLUME                   - Local storage volume management.
VOLUMEQUOTASETTING       - Associates the disk quota setting with a specific disk volume.
VOLUMEUSERQUOTA          - Per user storage volume quota management.
WMISET                   - WMI service operational parameters management.

For more information on a specific alias, type: alias /?

CLASS     - Escapes to full WMI schema.
PATH      - Escapes to full WMI object paths.
CONTEXT   - Displays the state of all the global switches.
QUIT/EXIT - Exits the program.

For more information on CLASS/PATH/CONTEXT, type: (CLASS | PATH | CONTEXT) /?

wmic:root\cli>cpu
AddressWidth  Architecture  Availability  Caption                             。。。。。。
64            9             3             AMD64 Family 16 Model 5 Stepping 3  。。。。。。

wmic:root\cli>cpu /? #查看CPU都有哪些命令

CPU - CPU management.

HINT: BNF for Alias usage.
(<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb clause>].

USAGE:

CPU ASSOC [<format specifier>]
CPU CREATE <assign list>
CPU DELETE
CPU GET [<property list>] [<get switches>]
CPU LIST [<list format>] [<list switches>]

wmic:root\cli>cpu list /? #查看CPU子命令的帮助

Property list operations.
USAGE:

LIST [<list format>] [<list switches>]

The following LIST formats are available:

BRIEF                     - Caption, DeviceID, Manufacturer, MaxClockSpeed, Name, SocketDesignation
CONFIG                    - AddressWidth, DataWidth, DeviceID, ExtClock, L2CacheSize, L2CacheSpeed, MaxClockSpeed, PowerManagementSupported, ProcessorType, Revisi
FULL                      - AddressWidth, Architecture, Availability, Caption, ConfigManagerErrorCode, ConfigManagerUserConfig, CpuStatus, CreationClassName, Curr
INSTANCE                  - DeviceID
STATUS                    - Availability, CpuStatus, CurrentVoltage, DeviceID, ErrorCleared, ErrorDescription, LastErrorCode, LoadPercentage, Status, StatusInfo

The following LIST switches are available:

/TRANSLATE:<table name>      - Translate output via values from <table name>.
/EVERY:<interval> [/REPEAT:<repeat count>] - Returns value every (X interval) seconds, If /REPEAT specified the command is executed <repeat count> times.
/FORMAT:<format specifier>   - Keyword/XSL filename to process the XML results.

NOTE: Order of /TRANSLATE and /FORMAT switches influences the appearance of output.
Case1: If /TRANSLATE precedes /FORMAT, then translation of results will be followed by formatting.
Case2: If /TRANSLATE succeeds /FORMAT, then translation of the formatted results will be done.

wmic:root\cli>cpu list brief #使用例子
Caption                             DeviceID  Manufacturer  MaxClockSpeed  Name                                SocketDesignation
AMD64 Family 16 Model 5 Stepping 3  CPU0      AuthenticAMD  3000           AMD Athlon(tm) II X4 640 Processor  CPU 1

wmic:root\cli>cpu get name #使用例子
Name
AMD Athlon(tm) II X4 640 Processor

直接输出,方便程序直接调用

C:\Users\cstriker1407>wmic cpu get name
Name
AMD Athlon(tm) II X4 640 Processor

 

发表评论

12 − 6 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据