次の方法で共有


Running Windows Management Instrumentation Command-line

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Running Windows Management Instrumentation Command-line

When you run Windows Management Instrumentation Command-line (WMIC) for the first time, it compiles Alias definitions, or Managed Object Format (MOF) files. Whenever MOF files are changed, WMIC recompiles the files and updates the repository.

You can choose to use WMIC in interactive mode or non-interactive mode. The following gives you some information about the characteristics and functions of the two modes:

Interactive mode

WMIC in interactive mode returns you to the WMIC command prompt after executing a command. Root\cli is the default WMIC role, and is there when you starts WMIC in interactive mode. The Exit or Quit command is used to exit WMIC.

Interactive mode is useful if you are entering a series of WMIC commands.

To start WMIC in interactive mode see Run WMIC in interactive mode.

The following examples include aliases, commands, and global switches that you can enter at the WMIC prompt when in interactive WMIC mode:

  • CONTEXT - lists all environment variables (Global switches).

  • OS - displays data about operating system in a default TABLE format.

  • OS list full - displays OS alias data in LIST format.

  • /? - lists descriptions of available environment variables and alias.

    • OS /? - lists options available for operating systems.

    • OS list /? - specifies formats for "list" operations.

    • OS list full /? - lists switches available.

    • OS list full /format /? - lists keywords for available formats.

    • OS call /? - lists methods (verbs) available.

    • OS get /? - lists properties available.

Non-Interactive mode

WMIC in non-interactive mode exits WMIC after performing the command you entered. You are returned to the WMIC command prompt when the command is completed. WMIC aliases, global switches, or commands can also be used in non-interactive mode.

Non-interactive mode is useful if you use WMIC for a batch procedure, or if you only need to execute one WMIC command.

To start WMIC in non-interactive mode see Run WMIC in non-interactive mode.

The following examples show how you can run commands in non-interactive mode:

  • <PROMPT>wmic os get /format:hform>MyOS.htm

    The output is directed to a html file, and you are returned to the command prompt where you started.

  • <PROMPT>wmic /?

    The Help is listed, and you are returned to the command prompt where you started

For more information, see Windows Management Instrumentation Command-line.