WMIC may display information about a very large number of computer resources, so you always must indicate the type of information you want via a resource name called alias; the simplest one is DataFile, that provide information about files. After the alias you may put a where clause, that select the desired data files, and a verb clause, that indicate the requested information. For example, the following command display all available information of all files in the disk (and take toooo long to complete):
Code: Select all
wmic datafile
The where clause take this form:where (propertyName=value [and propertyName=value] ...) although not all properties are allowed here. Note that path names in this clause must start and end with \\ and every intermediate \ in the path must be expanded to double \\; also, string values must be enclosed in quotes.
The Batch file below display the properties given in the parameters of the files in current directory, besides Name. Note that properties are always displayed in alphabetic order.
Properties.bat:
Code: Select all
@echo off
set properties=Name
:nextParam
if "%1" == "" goto endParams
set properties=%properties%, %1
shift
goto nextParam
:endParams
set drive=%CD:~0,2%
set folder=%CD:~2%
wmic datafile where (drive="%drive%" and path="%folder:\=\\%\\") get %properties%
Code: Select all
properties CreationDate LastAccessed FileType
Another interesting alias are:
Code: Select all
wmic BaseBoard get Description, InstallDate, Manufacturer, Model, Name, SerialNumber, Version
wmic ComputerSystem get CurrentTimeZone, Description, InstallDate, Manufacturer, Model, Name, NumberOfProcessors, TotalPhysicalMemory
Before the alias you may include global switches to modify the scope used by WMIC to retrieve or provide the requested information. The most useful ones are:
Code: Select all
/TRACE:ON
Specify whether output debug information is to be copied to stderr.
/{OUTPUT|APPEND}:CLIPBOARD|<filename>
Specifies the mode and destination for output redirection.
I encourage you to add additional details on wmic usage if you know that for the benefit of all of us!
Antonio