China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-08 08:36
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] Viewing Detailed Computer Hardware Information with Batch Processing View 4,250 Replies 16
Original Poster Posted 2007-11-25 01:50 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
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 ]
致精致简!
Floor 2 Posted 2007-11-25 03:07 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
You can use WMIC to get some things, such as the model and size of the hard disk:
wmic DiskDrive get Size,Model


You can explore other things by yourself.

There are also some third-party tools available.
Floor 3 Posted 2007-11-25 03:17 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
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
wmic path Win32_DiskDrive get index,interfacetype,model,size


devcon.exe query hard disk
@echo off
setlocal enabledelayedexpansion
echo Hard disk model Interface type Revision version
echo ======== ======== ========
for /f "tokens=1,2* delims=\" %%a in ('devcon.exe find gendisk^|find /v /i "USBSTOR\"^|find ":"') do call :fastslz "%%a" "%%b" "%%c"
echo.&pause
:fastslz
set "Fill spaces= "
set Type=%~1%Fill spaces%
set Revision=%~2
set Revision=%Revision:_= %
for %%i in (%Revision%) do set Revision=%%i
for /f "tokens=1* delims=:" %%a in ('echo %3') do set Model="%%~b"
set Model=%Model:~0,30%
set Model=%Model:"=%%Fill spaces%
set Model=%Model:~1,30%
echo %Model%%Type:~0,12%%Revision%
goto:eof


Also refer to http://www.cn-dos.net/forum/viewthread.php?tid=35139&fpage=1
Will continue later~~~~~~
第一高手 第二高手

Floor 4 Posted 2007-11-25 03:21 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Haha~ lxmxn isn't asleep either~
第一高手 第二高手

Floor 5 Posted 2007-11-25 03:49 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
WMIC is indeed powerful, but it's a pity I don't know English, alas!
致精致简!
Floor 6 Posted 2007-11-25 04:34 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
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...
Floor 7 Posted 2007-11-25 10:43 ·  中国 上海 电信
高级用户
★★★
Credits 916
Posts 377
Joined 2004-03-08 00:00
22-year member
UID 19523
Gender Male
Status Offline
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
Floor 8 Posted 2007-11-25 15:39 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Found online


@echo off
color 0a
title Hardware Detection
mode con cols=90
sc config winmgmt start= auto >nul 2<&1
net start winmgmt 2>1nul
setlocal ENABLEDELAYEDEXPANSION
echo Mainboard:
for /f "tokens=1,* delims==" %%a in ('wmic BASEBOARD get Manufacturer^,Product^,Version^,SerialNumber /value') do (
set /a tee+=1
if "!tee!" == "3" echo Manufacturer = %%b
if "!tee!" == "4" echo Model = %%b
if "!tee!" == "5" echo Serial Number = %%b
if "!tee!" == "6" echo Version = %%b
)
set tee=0
echo BIOS:
for /f "tokens=1,* delims==" %%a in ('wmic bios get

CurrentLanguage^,Manufacturer^,SMBIOSBIOSVersion^,SMBIOSMajorVersion^,SMBIOSMinorVersion^,ReleaseDate /value') do (
set /a tee+=1
if "!tee!" == "3" echo Current Language = %%b
if "!tee!" == "4" echo Manufacturer = %%b
if "!tee!" == "5" echo Release Date = %%b
if "!tee!" == "6" echo Version = %%b
if "!tee!" == "7" echo SMBIOSMajorVersion = %%b
if "!tee!" == "8" echo SMBIOSMinorVersion = %%b
)
set tee=0
echo.
echo CPU:
for /f "tokens=1,* delims==" %%a in ('wmic cpu get name^,ExtClock^,CpuStatus^,Description /value') do (
set /a tee+=1
if "!tee!" == "3" echo Number of CPUs = %%b
if "!tee!" == "4" echo Processor Version = %%b
if "!tee!" == "5" echo External Clock = %%b
if "!tee!" == "6" echo Name and Main Frequency = %%b
)
set tee=0
echo.
echo Monitor:
for /f "tokens=1,* delims==" %%a in ('wmic DESKTOPMONITOR get name^,ScreenWidth^,ScreenHeight^,PNPDeviceID /value') do (
set /a tee+=1
if "!tee!" == "3" echo Type = %%b
if "!tee!" == "4" echo Other Information = %%b
if "!tee!" == "5" echo Screen Height = %%b
if "!tee!" == "6" echo Screen Width = %%b
)
set tee=0
echo.
echo Hard Disk:
for /f "tokens=1,* delims==" %%a in ('wmic DISKDRIVE get model^,interfacetype^,size^,totalsectors^,partitions /value') do (
set /a tee+=1
if "!tee!" == "3" echo Interface Type = %%b
if "!tee!" == "4" echo Hard Disk Model = %%b
if "!tee!" == "5" echo Number of Partitions = %%b
if "!tee!" == "6" echo Capacity = %%b
if "!tee!" == "7" echo Total Sectors = %%b
)
echo Partition Information:
wmic LOGICALDISK where mediatype='12' get description,deviceid,filesystem,size,freespace
set tee=0
echo.
echo Network Card:
for /f "tokens=1,* delims==" %%a in ('wmic NICCONFIG where "index='1'" get ipaddress^,macaddress^,description /value') do (
set /a tee+=1
if "!tee!" == "3" echo Network Card Type = %%b
if "!tee!" == "4" echo Network Card IP = %%b
if "!tee!" == "5" echo Network Card MAC = %%b
)
set tee=0
echo.
echo Printer:
for /f "tokens=1,* delims==" %%a in ('wmic PRINTER get caption /value') do (
set /a tee+=1
if "!tee!" == "3" echo Printer Name = %%b
)
set tee=0
echo.
echo Sound Card:
for /f "tokens=1,* delims==" %%a in ('wmic SOUNDDEV get name^,deviceid /value') do (
set /a tee+=1
if "!tee!" == "3" echo Other Information = %%b
if "!tee!" == "4" echo Model = %%b
)
set tee=0
echo.
echo Memory:
for /f "tokens=1,* delims==" %%a in ('systeminfo^|find "Memory"') do (
echo %%a 4534 %%b
)
echo.
echo Graphics Card:
del /f "%TEMP%\temp.txt" 2>nul
dxdiag /t %TEMP%\temp.txt
:Graphics Card
rem It takes about 30 seconds here!
if EXIST "%TEMP%\temp.txt" (
for /f "tokens=1,2,* delims=:" %%a in ('findstr /c:" Card name:" /c:"Display Memory:" /c:"Current Mode:" "%TEMP%\temp.txt"') do (
set /a tee+=1
if !tee! == 1 echo Graphics Card Model: %%b
if !tee! == 2 echo Video Memory Size: %%b
if !tee! == 3 echo Current Setting: %%b
) ) else (
ping /n 2 127.1>nul
goto Graphics Card
)
set /p var=Do you need additional information?(y/n):
if /i %var% == y notepad "%TEMP%\temp.txt"
del /f "%TEMP%\temp.txt" 2>nul
pause

Floor 9 Posted 2007-11-25 16:29 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
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.
欢迎你到批处理爱好者联盟QQ群:18023953
Floor 10 Posted 2007-11-25 17:16 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
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
@echo off
wmic path Win32_Processor Get Caption,name,L2CacheSize,ExtClock,MaxClockSpeed /format:list
pause


Video
@echo off
WMIC PATH Win32_VideoController Get name,VideoModeDescription,CurrentRefreshRate,CurrentBitsPerPixel /format:list
pause
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
everest79 +15 2007-11-25 17:49
26933062 +8 2007-11-26 01:46
第一高手 第二高手

Floor 11 Posted 2007-11-25 17:49 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Floor 12 Posted 2007-11-25 19:53 ·  中国 广东 汕头 潮阳区 电信
高级用户
★★★
DOS时空
Credits 713
Posts 348
Joined 2007-02-10 13:59
19-year member
UID 79169
Gender Male
Status Offline
This function is good.!!!!!!!!!!!!!!!!!!NB
Floor 13 Posted 2007-11-26 01:45 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
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!!!
致精致简!
Floor 14 Posted 2007-11-26 02:27 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
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.
Floor 15 Posted 2007-12-06 15:15 ·  中国 上海 浦东新区 电信
高级用户
★★★
中國DOS聯盟常任參議员
Credits 686
Posts 318
Joined 2005-11-04 13:00
20-year member
UID 77577
Gender Male
Status Offline
I don't understand English, slowly absorb
. 繽紛色彩閃出的美麗是因為它沒有分開每種色彩...>/

我的百度空间: BEYOND超越 为什么用DOS
Forum Jump: