中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-08 07:34
47,811 topics / 349,895 posts / today 2 new / 48,253 members
DOS批处理 & 脚本技术(批处理室) » [Closed] Viewing Detailed Computer Hardware Information with Batch Processing
Printable Version  4,243 / 16
Floor1 26933062 Posted 2007-11-25 01:50
银牌会员 Posts 879 Credits 2,268
View detailed hardware information of the computer with batch processing
Requirement: Display the results roughly as follows

Hard disk model... size...
Memory model... size...
Graphics card model... size...
Motherboard model...
CPU model...
...
...
and so on...
In short, the more detailed the better. I wonder if batch processing can do it?
If batch processing can't do it, VBS is also okay.

[ Last edited by HAT on 2008-10-21 at 12:21 ]
Floor2 lxmxn Posted 2007-11-25 03:07
版主 Posts 4,938 Credits 11,386
You can use WMIC to get some things, such as the model and size of the hard disk:


You can explore other things by yourself.

There are also some third-party tools available.
Floor3 fastslz Posted 2007-11-25 03:17
铂金会员 Posts 2,315 Credits 5,493 From 上海
As far as I know, WMIC can find out. Originally wanted to post a post about WMIC application logs on the network log (Blog), but I'm too lazy and afraid of those English words.

WMIC query hard disk


devcon.exe query hard disk


Also refer to http://www.cn-dos.net/forum/viewthread.php?tid=35139&fpage=1
Will continue later~~~~~~
Floor4 fastslz Posted 2007-11-25 03:21
铂金会员 Posts 2,315 Credits 5,493 From 上海
Haha~ lxmxn isn't asleep either~
Floor5 26933062 Posted 2007-11-25 03:49
银牌会员 Posts 879 Credits 2,268
WMIC is indeed powerful, but it's a pity I don't know English, alas!
Floor6 lxmxn Posted 2007-11-25 04:34
版主 Posts 4,938 Credits 11,386
Originally posted by fastslz at 2007-11-25 03:21:
Haha~ lxmxn isn't asleep either~

Staying up late frequently has made me look much more haggard. Ashamed...
Floor7 dato Posted 2007-11-25 10:43
高级用户 Posts 377 Credits 916
Give this a try. There are some really nice things on this website. I only found out about this tool after doing a hardware inventory in the computer lab a while ago. It's really great. You can use psexec to complete the inventory of all machines on the local area network with it.

Console Computer Information Utility for 2000/XP
http://www.beyondlogic.org/solutions/compinfo/compinfo.htm
Floor8 everest79 Posted 2007-11-25 15:39
金牌会员 Posts 1,127 Credits 2,564
Found online

Floor9 htysm Posted 2007-11-25 16:29
高级用户 Posts 415 Credits 866
The batch script upstairs is really powerful. After testing, it was found that there are errors. Those with dual - core are said to be single - core, and those with serial hard drives are said to be IDE.
Floor10 fastslz Posted 2007-11-25 17:16
铂金会员 Posts 2,315 Credits 5,493 From 上海
Brother 26933062, I've organized some Wmic nodes and placed them in the network log. Go check it out. Your CMD is also very powerful; you can go get other types and then use for to get the result.
http://www.cn-dos.net/forum/viewthread.php?tid=35681&fpage=1

CPU


Video
Floor11 everest79 Posted 2007-11-25 17:49
金牌会员 Posts 1,127 Credits 2,564
Floor12 haiou327 Posted 2007-11-25 19:53
高级用户 Posts 348 Credits 713
This function is good.!!!!!!!!!!!!!!!!!!NB
Floor13 26933062 Posted 2007-11-26 01:45
银牌会员 Posts 879 Credits 2,268
Thanks to the enthusiasm of brother fastslz, I've always wanted to understand wmic, but because I don't know English, I've been completely at a loss with wmic. With your sorted-out materials, it must be of great help to me. Thanks!!!
Floor14 HAT Posted 2007-11-26 02:27
版主 Posts 5,017 Credits 9,023
WMIC: Comprehensive Management of Windows from the Command Line
Starting from Windows 2000, WMI (Windows Management Instrumentation) has been an important part of Windows system management. WMIC is the abbreviation of Windows Management Instrumentation Command-line. Before the appearance of WMIC, it was not an easy task to access the WMI database or WMI namespace from the command line. Now, WMIC uses the powerful functions of WMI to extend system management to the command line.

1. What is WMIC?

WMIC extends WMI and provides support for performing system management from the command line interface and batch command scripts. Before the appearance of WMIC, if you wanted to manage the WMI system, you had to use some specialized WMI applications, such as SMS, or use the WMI scripting programming API, or use tools like CIM Studio. If you were not familiar with programming languages like C++ or scripting languages like VBScript, or did not master the basic knowledge of the WMI namespace, it was very difficult to manage the system with WMI. WMIC has changed this situation and provided a powerful and friendly command line interface for the WMI namespace.

WMIC is much simpler and more intuitive than WMI, mainly due to the use of aliases. The alias mechanism obtains some simple commands entered by the user on the command line and operates the WMI namespace in a predefined way. For example, a complex WMI Query Language (WQL) command is constructed according to a simple WMIC alias Get command. In this sense, the alias is an intermediate layer that simplifies the operation between the user and the namespace. For example, if you execute the following simple WMIC command on the WMIC command line, you can obtain the basic information of the user account:

useraccount list brief

In the above command, the Useraccount alias executes a WQL query of the Win32_Useraccount class and displays the information extracted from this class in text form. In addition, WMIC also displays the attributes of the Win32_Useraccount class in text form. In addition to text-form output, WMIC can also return the command execution result in other forms, such as XML, HTML, or CSV (comma-separated text file).

WMIC saves aliases in the form of instances of classes in the WMI schema. The default alias class - MSFT_CliAlias, and other classes supporting WMIC are saved in the default namespace of the schema, or the root\cli role. The role can be simply regarded as another WMI namespace specially used to support WMIC. The default role root\cli is connected to the root\cimv2 namespace and operates the classes within root\cimv2. Although CIM Studio is generally not needed when using WMIC, CIM Studio can be used to conveniently view the root\cli namespace.

You can add new aliases to the root\cli namespace and other namespaces, and you can directly access the WMI namespace using the Class and Path commands. The Class and Path commands will be described in detail later in this article.

2. Running WMIC

Execute the "wmic" command to start the WMIC command line environment. This command can be executed in the standard command line interpreter (cmd.exe) of XP or.NET Server, Telnet session, or "Run" dialog box. These startup methods can be used locally or through a.NET Server terminal services session.

When executing the WMIC command for the first time, Windows will first install WMIC, and then display the WMIC command line prompt. On the WMIC command line prompt, commands are executed interactively. For example, executing the following command will close the running Outlook:

process where name='outlook.exe' call terminate

After the command is executed, the WMIC command line prompt reappears. Each command must be entered in one line, and no line breaks can be inserted in the middle.

WMIC can also run in non-interactive mode. Non-interactive mode is useful if you want to perform a single-step task or run a series of WMIC commands in a batch command. To use non-interactive mode, just start WMIC on the same command line and enter the command to be executed. For example, open a command line window by executing cmd.exe, and then execute the following command to output the list of printers connected to MACHINE1:

wmic /node:MACHINE1 printer list status

In this example, the first operation is to start WMIC, then establish a remote connection to MACHINE1 according to the /node parameter, and finally execute a WMIC command to display the printer status information. After the command is executed, it returns to the Windows command line prompt state.

A machine with WMIC installed can connect to any machine with WMI installed, and the connected machine does not need to install WMIC. For example, starting WMIC from a machine running Win XP Pro can connect and manage all machines running XP, Win2K, Windows NT 4.0, Windows Me, and Windows 9x.

3. Composition of the WMIC Command Line

WMIC provides a large number of global switches, aliases, verbs, commands, and rich command line help to enhance the user interface. Global switches are configuration options applicable to the entire WMIC session. For example, the /trace:on switch enables the error tracking mechanism. If this switch is on, WMIC returns the error information of each command. The /note switch can be used to access a remote machine, the /interactive:on switch requires WMIC to prompt for confirmation before performing a delete operation. Other global switches include /role, /user, /implevel, and /namespace.

As mentioned earlier, the alias is an intermediate layer that simplifies the syntax between the user and the WMI namespace. When you specify an alias, the verb indicates the action to be performed. For example, List and Call in the previous example are examples of two verbs. Table 1 describes some other WMIC verbs and gives examples for each verb.

Table 1: WMIC Verbs
Verb Example Description
Assoc group where name= 'administrators' assoc Displays all associations between the Administrators group and the system, including members of the Administrators group, etc. Also, os assoc displays information about the operating system and installed patches.
Create environment create name="progloc", username="work01\User1",variablevalue= "%programfiles%\prog01" Creates a variable named Progloc, sets its value to a subfolder of the Program Files folder, and adds this variable to the User1 account of the Work01 workgroup computer.
Delete environment where(name= "progloc") delete Deletes the Progloc environment variable. When testing WMIC commands, to prevent accidental deletion, you can use the /interactive:on global switch, which will require confirmation before deletion.
Get partition get bootpartition, description, deviceid, bootable Returns information such as whether the partition is bootable, description information, and device ID attributes.
Set path WIN32_USERACCOUNT where(name="user01") set disabled="true" Disables the User01 user account on a member server or workstation.

Commands are used to control access to WMIC and the WMI namespace. Note the last example in Table 1. This example uses the Path and Win32_USERACCOUNT class, not the Useraccount alias. The Path is a command to directly access an instance in the WMI namespace, and there is no need to access it through an alias. The Path command is especially useful when there is no ready-made alias available for the system management task to be performed. Although you can extend WMIC with new aliases and roles, if you are familiar with the WMI namespace, using the Path command is also convenient.

In addition to the Path command, WMIC also supports the Class, Context, Quit, and Exit commands. The Class command is used to directly access classes in the WMI schema or create instances of existing classes. The difference between the Class command and the Path command is that the Path command acts on instances and their attributes (for example, extracting information for management), while the Class command acts on the definition of classes. For example, if you want to extract all attributes of the WIN32_SOFTWAREELEMENT class, you can execute the following command:

class WIN32_SOFTWAREELEMENT get

The output of this command is in HTML format. Later, we will learn how to use the /output global switch to redirect the output to an HTML file that can be opened with a browser. The Class command plus the Assoc verb can display the namespace path of the class and other classes associated with this class. The Class command can be used to delete classes and create instances of classes, but cannot create classes.

The Context command displays the current settings of global switches. The Quit and Exit commands are used to exit the WMIC command prompt environment and return to the previous Shell environment (for example, the Telnet environment or the XP command line prompt environment).

Command line help is an effective way to become familiar with WMIC. Table 2 is a common command for finding information under the WMIC prompt:

4. Practical Application

We have learned the basic knowledge of the WMIC command line environment above. Now let's see how to run WMIC with a batch command and redirect the output result to the console or to HTML, XML files. The advantage of running WMIC from a batch command file is that you don't need to repeatedly enter a series of complex commands. For example, the following is the content of a batch command file, which is used to display the CPU information of two machines, MACHINE1 and MACHINE4, and the output result is displayed on the console. The /format switch is a verb-oriented switch, not a global switch, and it is only used for the Get and List verbs.

wmic /node:MACHINE1, MACHINE4 cpu get name, caption,
maxclockspeed, systemname /format:textvaluelist.xsl

WMIC batch commands can use variables. That is to say, for the above batch command, the name of the server can not only be specified directly, but also can be specified in the form of %1, %2. The following is an example. Put the following code into a batch command file, and then add one or two machine names when executing the batch command file; in addition, you can also create an independent text file, and then put the list of machine names in the text file. The list can be in CSV format or in a format separated by line breaks. If an independent text file is used to provide the machine names, just add the text file name prefixed with the @ symbol after the /node global switch. The @ symbol tells the /node switch that the parameter behind is a file name, not a machine name.

@echo off
if "%1"=="" goto msg
if "%2"=="" goto single
wmic /node:%1, %2 cpu get name, caption, maxclockspeed, systemname
/format:textvaluelist.xsl
goto end
:single
wmic /node:%1 cpu get name, caption, maxclockspeed,
systemname /format:textvaluelist.xsl
goto end
:msg
echo 必须指定至少一台计算机的名字。
:end

As mentioned earlier, the output result of the WMIC command can not only be sent to the console, but also to XML or HTML, MOF (Managed Object Format) format files. On a computer with WMI installed, MOF is the original storage form of classes and class instances in the WMI database. The following example shows how to output the query result of the processor information of MACHINE4 to an HTML file. The /output global switch requires WMIC to send the output to file1.htm, and the /format switch requires WMIC to convert the original XML output into HTML format. The XSL style file used for format conversion can be a custom one or any XSL file in the \%systemroot%\system32\wbem folder on any machine with WMIC installed. For example, using the csv.xsl style file can convert the output result into CSV format, and using the htable.xsl style can construct a table containing the result data.

wmic /node:MACHINE4 /output:e:\file1.htm cpu get description,
maxclockspeed, extclock, manufacturer, revision /format:hform.xsl

As mentioned earlier, the default output of the Class command plus the Get verb is in HTML format. Therefore, if you want to save the output result of such a command to an HTML file, you only need to specify the /output switch, and there is no need to add the /format switch. The /record and /append global switches can also intercept information from the WMIC command line. Please use the command line help function of WMIC to learn more about these switches.

If you want to output in XML format, use the /translate switch and the Basicxml keyword to convert the greater-than symbol ">" and the less-than symbol "<" into meaningful characters in XML. The following is an example of outputting XML. The output XML data can be imported into a database or other systems that can understand XML tags. The output of the following code includes the WMIC command, the command line request parameters, the target node, the global switches, and the command execution result.

wmic cpu get maxclockspeed /translate:basicxml /format:rawxml.xsl

In conclusion, WMIC is an important improvement in the command line management function in XP and.NET Server, and provides robust support for accessing and managing the WMI namespace from the command line. Although it takes some time to master and be familiar with the WMIC command line environment, once you are familiar with it, a brand new realm of system management will be presented to you.
Floor15 Jneny Posted 2007-12-06 15:15
高级用户 Posts 318 Credits 686
I don't understand English, slowly absorb
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023