WMIC - CMD


Overview

Windows Management Instrumentation Command-line (WMIC) is a scripting interface that simplifies the use of Windows Management Instrumentation (WMI) and systems managed through WMI. WMIC enables users to perform administrative operations on local or remote computers, including querying for detailed system information, setting configurations, managing processes, and much more. It is a powerful tool especially useful in network administration and system troubleshooting.

Syntax

The basic syntax for WMIC is:

wmic [alias] [where clause] [verb clause]
  • alias: Represents the WMI class.
  • where clause: Filters the objects to act upon.
  • verb clause: Specifies the action to perform.

Extended Syntax:

wmic /node: '<nodeName1,nodeName2>' /user: '<username>' /password: '<password>' /output: '<filePath>' [alias] [verb] [properties]

Options/Flags

  • /node: Specifies the target computer. Default is the local system.
  • /user: Defines the username for login to the target computer.
  • /password: Password for the user.
  • /output: Directs the output of the command to a file instead of the command line.
  • /append: Appends the output to an existing file.
  • /locale: Sets the language locale for the output.
  • /namespace: Specifies the WMI repository namespace to use.
  • /role: Defines the role for node-level operations.

Examples

  1. Basic Query

    wmic os get name
    

    Displays the name of the operating system.

  2. Detailed System Information

    wmic os get /format:list
    

    Lists all properties of the operating system in a detailed format.

  3. Getting Serial Number of the System

    wmic bios get serialnumber
    

    Retrieves the serial number of BIOS.

  4. Stopping a Process

    wmic process where name='notepad.exe' delete
    

    Terminates all instances of Notepad.

Common Issues

  • Access Denied: Make sure you have administrative privileges especially when dealing with remote systems.
  • Invalid Global Switch: Incorrect syntax or typographical errors can cause this issue. Double check the command syntax.
  • Node Unreachable: Ensure the remote system is available and reachable over the network.

Integration

WMIC can be used in conjunction with batch scripts to automate tasks across many systems. For example:

for /f %%i in (servers.txt) do wmic /node:%%i product where "name like 'Adobe Reader%'" call uninstall

This script reads server names from servers.txt and uninstalls Adobe Reader from each.

  • Get-WmiObject (gwmi): PowerShell equivalent of WMIC, providing more flexibility and integration with modern Windows features.
  • powershell.exe: Can be used to execute more complex scripts that are beyond the scope of simple command-line commands.

Further reading and detailed information can be accessed through the Microsoft Docs website or the respective command help pages by running wmic /? or help wmic in the command prompt.