WMIC (Windows Management Interface Command) commands
You may have heard about WMIC while working with Windows operating system. If not, in this blog you will get to know about WMIC things that are required to work with windows management commands.
Open command prompt by using Search or Run option from start menu.
Type below command to get all the available options with WMIC:
wmic /?
We will see some of the available options in this blog.
- COMPUTERSYSTEM — Computer system management.
This global switch provides information about your computer system like DNSHostName, Domain, Manufacturer, Model, Name, NumberOfLogicalProcessors, UserName etc.
But, how will you know what are the details this global switch provides. Don’t worry, use below command to get the all available details under this switch.
wmic COMPUTERSYSTEM
You can get specific details by querying as shown below:
wmic COMPUTERSYSTEM get DNSHostName, Manufacturer, Model, NumberOfLogicalProcessors
2. CPU — CPU management
Using this option you will get many details related to the system CPU like Manufacturer, MaxClockSpeed, Name, NumberOfCores, NumberOfLogicalProcessors, ProcessorId etc.
Use below command to get the all available details under this switch.
wmic CPU
You can get specific details by querying as shown below:
wmic CPU get Name, NumberOfCores, ProcessorId
3. LOGICALDISK — Local storage device management
You may find this option very useful if you are working with windows based logical disk drive management. This option provides many details like Caption, DriveType, FileSystem, FreeSpace, Size etc.
Use below command to get the all available details under this switch.
wmic LOGICALDISK
You can get specific details by querying as shown below:
wmic LOGICALDISK get Caption, DriveType, FileSystem, FreeSpace, Size
Even you can query using the where clause, interesting right? See below:
wmic LOGICALDISK where Caption=”C:” get Caption, DriveType, FileSystem, FreeSpace, Size
4. NIC — Network Interface Controller (NIC) management
This global switch provides information about all the Network Interfaces available with the system. Let’s see how to get the information:
wmic NIC
You can get specific details by querying as shown below:
wmic NIC get AdapterType, AdapterTypeId, MACAddress, NetEnabled
Observe the empty lines in the above image after the header line. This is because we are getting all the available details with the system where some information is not available with network interfaces.
Let’s use WHERE clause to get only valid data:
wmic NIC where AdapterTypeId=0 get AdapterType, AdapterTypeId, MACAddress, NetEnabled
5. OS — Installed Operating System/s management
You may find this global switch very useful in case you want details about the windows operating system like OSArchitecture, FreePhysicalMemory, InstallDate, Manufacturer, NumberOfLicensedUsers, NumberOfProcesses, NumberOfUsers, SerialNumber, SystemDrive etc.
Let’s get all the available attributes with this global switch:
wmic OS
You can get specific details by querying as shown below:
wmic OS get OSArchitecture,Manufacturer, NumberOfProcesses, NumberOfUsers, SystemDrive
6. PROCESS — Process management
You will get all the details about current running processes while using this global switch like CommandLine, ExecutablePath, Name, ParentProcessId, Priority, ProcessId etc.
Get all the available attributes using below command:
wmic PROCESS
Whereas get the specific details using below command:
wmic PROCESS get Name, ParentProcessId, Priority, ProcessId
In fact you can terminate a specific process using where clause as shown below:
wmic PROCESS where ProcessId=7100 call terminate
Here, we are terminating a process which has ProcessId as 7100 (Process ID may be different in your case). See the output below:
If you don’t know the process ID, then you can also use process name to terminate the process.
wmic PROCESS where name=”notepad.exe” call terminate
Note:
- All the above commands are used & output is generated on Windows 7 Operating System. Using other windows platforms may result in different outputs.
- WMIC execution may require some administrative privileges or elevation.
Conclusion:
WMIC provides various commands over WMI to provide details regarding various global switches like Computer System, CPU, Logical Disk, Network Interfaces, Operating System etc. You can use WHERE clause to filter the results.
That’s it from my side. Any suggestions & corrections are highly welcomed.
Stay happy 😊 & keep reading.