Starting with Windows 2000, WMI (Windows Management Specification) is an important part of Windows System Management. WMIC is the abbreviation for Windows Management Instrumentation command-line, and it is not easy to access the WMI database or WMI namespace from the command line before WMIC appears. Today, WMIC extends system management to the command line, leveraging WMI's powerful capabilities.
One, what is WMIC?
WMIC extends WMI, providing support for system administration from command-line interfaces and batch command scripts. Before WMIC appears, if you want to manage the WMI system, you must use specialized WMI applications, such as SMS, or use WMI's scripting API, or use tools like CIM Studio. WMI management systems are difficult to use if you are unfamiliar with scripting languages like C + +, such as language or VBScript, or if you don't have the basics of WMI namespaces. WMIC changes this situation and provides a powerful, user-friendly command-line interface for the WMI namespace.
WMIC is much simpler and more intuitive than WMI, mainly because of the use of aliases (alias). The alias mechanism takes some simple commands that the user enters on the command line, manipulating the WMI namespace in a predefined manner, such as constructing a complex WMI Query Language (WQL) command based on a simple WMIC alias get command. In this sense, the alias is the middle tier of a simplified operation between the user and the namespace. For example, if you perform the following simple WMIC command on the WMIC command line, you can obtain basic information about the user account:
useraccount list brief
In the above command, the UserAccount alias performs a WQL query of the Win32_UserAccount class, displaying the information extracted from the class in the form of text. In addition, WMIC displays the properties of the Win32_UserAccount class in text form. In addition to text-form output, WMIC can return command execution results in other forms, such as XML, HTML, or CSV (comma-delimited text files).
WMIC saves aliases in the form of instances of classes in WMI mode. The default alias class--msft_clialias, and other classes that support WMIC, are saved in the default namespace of the schema, or root\cli roles. Roles can be simply viewed as another WMI namespace specifically designed to support WMIC. The default role root\cli connects to the root\cimv2 namespace, manipulating the classes within the root\cimv2. While using WMIC does not typically require CIM Studio, CIM Studio can be used to easily view the Root\cli namespace. For example, figure one shows some of the properties of the ROOT\CLI node and the MSFT_CliAlias class.
You can add new aliases to the Root\cli namespace and other namespaces, and you can access the WMI namespace directly with the class and path commands, and the class and path commands are described in detail later in this article.
Second, running WMIC
Perform the WMIC command to start the WMIC command line environment. This command can be performed in the standard command-line interpreter (Cmd.exe), Telnet session, or Run dialog box of XP or. NET server. These boot methods can be used locally or through a. NET server Terminal Services session.
When the WMIC command is executed for the first time, Windows first installs WMIC and then displays the command line prompt for WMIC. On the WMIC command-line prompt, the command executes interactively. For example, executing the following command closes Outlook that is running:
process where name='outlook.exe' call terminate
After the command runs, the WMIC command-line prompt appears again, as shown in Figure two. Each command must be entered within one line and the newline character cannot be inserted in the middle.
WMIC can also run in a 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, simply start WMIC on the same command line and enter the command you want to execute. For example, executing cmd.exe opens a command-line window, and then executes the following command to output a 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 based on the/node parameter, and finally execute a WMIC command to display the printer status information. When the command is run, return to the Windows command prompt state.
A machine with WMIC installed can connect to any machine that has WMI installed, and the connected machine does not need to have WMIC installed. 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.