My
FindRepl.bat program have had support for WMI classes since the version 2 was released on 2014. In the description of
FindRepl.bat version 2, under the point 3.4, I explained the way to use the
Data generating predefined functions via the
/S and
/J switches. These functions create what in JScript are called
Collections that are just several items contained in a group.
Code: Select all
DATA GENERATING FUNCTIONS (collections)
drivesCollection(prop1,prop2,...) - Returns the specified list of properties for all drives in the system.
If no parameters are given, returns the Path property of all drives.
filesCollection(folder,prop1,prop2...) - Returns the specified list of properties for all Files in the given folder.
If no parameters are given, returns the Name property of files in current folder.
foldersCollection(folder,prop1,prop2..) - Returns the specified list of properties for all SubFolders in the given folder,
Files and SubFolders properties can not be directly given (see the description below).
If no parameters are given, returns the Name property of subfolders in current folder.
specialFolders(special,prop1,prop2...) - Returns the list of properties for all Files or SubFolders in the special folder;
the desired collection is selected by: 'special.Files' or 'special.SubFolders'.
If no parameters are given, returns the Path property of all special folders.
wmiCollection(class,prop1,prop2...) - Returns the specified list of properties for all elements in the given WMI class.
If just the class is given, returns the names of all properties in the class.
If no parameters are given, returns the names of all classes (in default namespace).
See: http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx
These are some examples of the use of such functions:
Code: Select all
C:\ FindRepl "/S:drivesCollection('Path','FreeSpace','TotalSize')" /J
"C:","423201288192","474821423104"
"D:","2942341120","24459079680"
"E:","Not ready","Not ready"
C:\ set "source=drivesCollection('Path','FreeSpace','TotalSize')"
C:\ FindRepl /S:=source /Q:# "#([^#]*)#,#([^#]*)#,#([^#]*)#\r\n" "$1+' = '+$2+' = '+$3+'\r\n'" /J
C: = 423201288192 = 474821423104
D: = 2942341120 = 24459079680
E: = Not ready = Not ready
C:\ set "search=#([^#]*)#,#([^#]*)#,#([^#]*)#\r\n"
C:\ FindRepl /S:=source /Q:# =search "$1+'\t'+(S=Math.floor(100-$2*100/$3))+'% Occupied'+(S>85?'\tRequires cleanup!':'')+'\r\n'" /J
C: 10% Occupied
D: 87% Occupied Requires cleanup!
E: NaN% Occupied
The wmiCollection predefined function is the key to have access to a huge amount of information related to the system. In order to not waste even more words in an over-described topic, you are encouraged to review the WMI documentation at the site linked in the FindRepl /help screen. Below there is a list of just a few useful classes and properties that appear in the first two divisions at
Microsoft Win32 provider site. The elements in the list are written as parameters of wmiCollection function (the class first, followed by its properties) so you may easily copy and paste they in the command line in order to execute FindRepl.bat program and show the result.
Code: Select all
1- Computer System Hardware Classes
'Win32_Keyboard','Description','DeviceID','Layout'
'Win32_DiskDrive','Description','MediaLoaded','SerialNumber','Status'
'Win32_PhysicalMemory','Capacity','Name','Speed'
'Win32_Processor','CurrentClockSpeed','DataWidth','Description','Manufacturer','Name','NumberOfCores'
'Win32_Battery','BatteryStatus','Description','DeviceID','EstimatedChargeRemaining','EstimatedRunTime','Status'
2- Operating System Classes
'Win32_Environment','Name','SystemVariable','UserName','VariableValue'
'Win32_SystemDriver','Name','ServiceType','Started','State'
'Win32_Directory','CreationDate','Extension','FileName','FileSize','FileType','LastAccessed','LastModified','Name','Status'
'Win32_DiskPartition','BootPartition','Caption','Size','Type'
'Win32_LogicalDisk','DeviceID','DriveType','FileSystem','FreeSpace','MediaType','Size','VolumeName'
'Win32_ComputerSystem','Description','Manufacturer','Model','NumberOfProcessors','SystemType','TotalPhysicalMemory','UserName'
'Win32_OperatingSystem','CountryCode','LocalDateTime','Name','RegisteredUser','SerialNumber','Version','WindowsDirectory'
'Win32_Process','Handle','Name','ParentProcessId'
'Win32_Service','Name','ServiceType','Started','State'
'Win32_LocalTime','Day','DayOfWeek','Hour','Minute','Month','Quarter','Second','WeekInMonth','Year'
'Win32_Account','Caption','Name','SID','Status'
'Win32_UserAccount','Caption','FullName','Name','SID','Status'
For example:
Code: Select all
C:\ FindRepl "/S:wmiCollection('Win32_LocalTime','Year','Month','Day','DayOfWeek','Hour','Minute','Second')" /J
"2022","2","21","1","14","25","14"
You must be aware that certain WMI requests may take several seconds, like class 'Win32_Directory' that returns the data
of all files and folders that exists in the disk, or executing wmiCollection() with no parameters in order to display the names of all existent classes in the default name space (root\cimv2).
Of course, you have not to use a program as large as FindRepl.bat in order to access the WMI collections via JScript. I will write a short version of Win32_LocalTime with the minimum code to show the date and time...
Antonio