Wednesday, August 19, 2009

Restarting WMI Services Using Command Line

Starting Winmgmt Service

The following procedure describes how to start the WMI service.

To start Winmgmt Service

    • At a command prompt, enter net start winmgmt [/].

For more information about the switches that are available, see winmgmt. You use the built-in Administrator account or an account in the Administrators group running with elevated rights to start the WMI service. For more information, see User Account Control and WMI.

Stopping Winmgmt Service

The following procedure describes how to stop the WMI Service.

To stop Winmgmt Service

  1. At a command prompt, enter net stop winmgmt.

  2. Other services that are dependent on the WMI service also halt, such as SMS Agent Host or Windows Firewall.

Windows 2000: For WMI failures that occur because of improper provider unloading, the REG_SZ registry key value should be set to 1 (one). The default value is 0 (zero).

HKLM\Software\Microsoft\WBEM\
CIMOM\Force Clean Shutdown

winmgmt

Winmgmt is the WMI service within the SVCHOST process running under the LocalSystem account. In all cases, the WMI service automatically starts when the first management application or script requests connection to a WMI namespace. For more information, see Starting and Stopping the WMI Service.

Windows 2000 and Windows NT 4.0: The WMI service runs as a separate service process.

When run from the command prompt, the WMI service has the following switches.

Switches

Term

Description

/backup

Causes WMI to back up the repository to the specified file name. The filename argument should contain the full path to the file location. This process requires a write lock on the repository so that write operations to the repository are suspended until the backup process is completed.

/restore

Manually restores the WMI repository from the specified backup file. The filename argument should contain the full path to the backup file location. To perform the restore operation, WMI saves the existing repository to write back if the operation fails. Then the repository is restored from the backup file that is specified in thefilename argument. If exclusive access to the repository cannot be achieved, existing clients are disconnected from WMI.

The flag argument must be a 1 (force — disconnect users and restore) or 0 (default — restore if no users connected) and specifies the restore mode.

/resyncperf

Registers the system performance libraries with WMI.

/standalonehost []

Moves the Winmgmt service to a standalone Svchost process that has a fixed DCOM endpoint. The default endpoint is "ncacn_ip_tcp.0.24158". However, the endpoint may be changed by running Dcomcnfg.exe. For more information about setting up a fixed port for WMI, see Setting Up a Fixed Port for WMI.

The level argument is the authentication level for the Svchost process. WMI normally runs as part of a shared service host and you cannot increase the authentication level for WMI alone. If levelis not specified, the default is 4 (RPC_C_AUTHN_LEVEL_PKT or WbemAuthenticationLevelPkt).

You can run WMI more securely by increasing the authentication level to Packet Privacy (RPC_C_AUTHN_LEVEL_PKT_PRIVACY or WbemAuthenticationLevelPktPrivacy). The authentication levels for Visual Basic and scripting are described inWbemAuthenticationLevelEnum. For C++, see Setting the Default Process Security Level Using C++. For more information, see Maintaining WMI Security.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is not available.

/sharedhost

Moves the Winmgmt service into the shared Svchost process.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is not available.

/verifyrepository

Performs a consistency check on the WMI repository. When you add the /verifyrepository switch without the argument, then the live repository currently used by WMI is verified. When you specify the path argument, you can verify any saved copy of the repository. In this case, the path argument should contain the full path to the saved repository copy. The saved repository should be a copy of the entire repository folder. For more information about errors returned by this command, see the Remarks section.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is not available.

/salvagerepository

Performs a consistency check on the WMI repository, and if an inconsistency is detected, rebuilds the repository. The content of the inconsistent repository is merged into the rebuilt repository, if it can be read. The salvage operation always works with the repository that the WMI service is currently using. For more information about errors returned by this command, see the Remarks section.

% MOF files that contain the #pragma autorecover preprocessor statement are restored to the repository.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is not available.

/resetrepository

The repository is reset to the initial state when the operating system is first installed. MOF files that contain the #pragma autorecover preprocessor statement are restored to the repository.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is not available.

Obsolete Switches

Term

Description

/exe

Causes Winmgmt.exe to run as an application rather than as a service. The primary use of the /exe switch is to allow you to debug providers more easily. When the /exe switch is used, Winmgmt.exe is run in the user security context. Normally, WMI should run as a service. Using this switch places an icon in the taskbar.

/kill

Terminates all Winmgmt.exe processes on the local system, including WMI processes started as a service by the Service Control manager or invoked by using the /exe switch. You must have administrative rights to use this switch.

Windows Vista and Windows Server 2008: This switch is not available. Instead use net stop wmiapsrv and net stop winmgmt at the command prompt.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is available.

/clearadap

The ADAP process is not available starting in Windows Vista. ThePerformance Counter Classes are created by the WMIPerfClass Provider and data is supplied by the WMIPerfInst Provider. Be aware that you can still use the wmiadap command for certain performance counter operations. For more information, seewmiadap.

Windows Server 2003, Windows XP, Windows 2000, Windows XP, and Windows NT 4.0: Removes all of the ADAP information from the registry, effectively resetting the state of each performance library. The ADAP utility stores state information about the system performance libraries in the registry.

/unregserver

Removes registry entries added through the self-registration process and should rarely be used.

Windows Vista and Windows Server 2008: This switch is not available. Instead use regsvr32 -u wmisvc.dll at the command prompt.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is available.

/regserver

Registers the Windows Management Service, adding entries to the operating system registry. The /regserver switch should be implemented by any .exe server.

Windows Vista and Windows Server 2008: This switch is not available. Instead use regsvr32 wmisvc.dll at the command prompt.

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This switch is available.

Remarks

The WMI repository, also known as the CIM repository, is not just a single file, but a collection of files within the Repository folder that work together as a database. When you use the /backup switch to backup the repository, the resulting backup is a single compressed file.

WMI returns the error ERROR_INTERNAL_DB_CORRUPTION (net helpmsg 1358) if a verification operation indicates that the repository is not in a consistent state. This error can be returned from any command which performs repository verification, such as /verifyrepository or /salvagerepository.

Note If WMI returns error messages, be aware that they may not indicate problems in the WMI service or in WMI providers. Failures can originate in other parts of the operating system and emerge as errors through WMI. Under any circumstances, do not delete the WMI repository as a first action because deleting the repository can cause damage to the system or to installed applications.

For more information about the source of the problem, download and run the WMI Diagnosis Utility diagnostic command line tool. This tool produces a report that can usually isolate the source of the problem and provide instructions on how to fix it. The report also aids Microsoft support services in assisting you. You can download theWMI Diagnosis Utility.

Requirements

Client

Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0 SP4 and later, Windows Me, Windows 98, or Windows 95.

Server

Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later.

DLL

Requires Winmgmt.exe.



No comments: