ManagementObject 参数 WMI 一些参数(Win32_Service)

本文详细介绍了 Win32_Service 类的各项属性,包括服务是否可暂停、停止、名称、状态等,帮助读者理解 Windows 服务的基本配置和管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

class Win32_Service : Win32_BaseService
{
  boolean AcceptPause;
  boolean AcceptStop;
  string Caption;
  uint32 CheckPoint;
  string CreationClassName;
  string Description;
  boolean DesktopInteract;
  string DisplayName;
  string ErrorControl;
  uint32 ExitCode;
  datetime InstallDate;
  string Name;
  string PathName;
  uint32 ProcessId;
  uint32 ServiceSpecificExitCode;
  string ServiceType;
  boolean Started;
  string StartMode;
  string StartName;
  string State;
  string Status;
  string SystemCreationClassName;
  string SystemName;
  uint32 TagId;
  uint32 WaitHint;
};

 

 

Properties

The Win32_Service class has the following properties.

AcceptPause
Data type: boolean
Access type: Read-only

 

Service can be paused.

 

AcceptStop
Data type: boolean
Access type: Read-only

 

Service can be stopped.

 

Caption
Data type: string
Access type: Read-only

 

Short description of the object—a one-line string.

 

CheckPoint
Data type: uint32
Access type: Read-only

 

Value that the service increments periodically to report its progress during a long start, stop, pause, or continue operation. For example, the service increments this value as it completes each step of its initialization when it is starting up. The user interface program that invokes the operation on the service uses this value to track the progress of the service during a lengthy operation. This value is not valid and should be zero when the service does not have a start, stop, pause, or continue operation pending.

 

CreationClassName
Data type: string
Access type: Read-only
Qualifiers: Key, MaxLen( 256)

 

Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified.

 

Description
Data type: string
Access type: Read-only

 

Description of the object.

 

DesktopInteract
Data type: boolean
Access type: Read-only

 

Service can create or communicate with windows on the desktop.

 

DisplayName
Data type: string
Access type: Read-only

 

Display name of the service. This string has a maximum length of 256 characters. The name is case-preserved in the Service Control Manager. However, DisplayName comparisons are always case-insensitive. Constraint: accepts the same value as the Name property.

Example: "Atdisk"

 

ErrorControl
Data type: string
Access type: Read-only

 

Severity of the error if this service fails to start during startup. The value indicates the action taken by the startup program if failure occurs. All errors are logged by the computer system.

ValueMeaning
"Ignore"User is not notified.
"Normal"User is notified.
"Severe"System is restarted with the last-known-good configuration.
"Critical"System attempts to restart with a good configuration.
"Unknown"Severity of the error is unknown.

 

ExitCode
Data type: uint32
Access type: Read-only

 

Windows error code defining any problems encountered in starting or stopping the service. This property is set to ERROR_SERVICE_SPECIFIC_ERROR (1066) when the error is unique to the service represented by this class, and information about the error is available in the ServiceSpecificExitCode property. The service sets this value to NO_ERROR when running, and again upon normal termination.

 

InstallDate
Data type: datetime
Access type: Read-only

 

Date object is installed. This property does not need a value to indicate that the object is installed.

 

Name
Data type: string
Access type: Read-only

 

Unique identifier of the service that provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.

 

PathName
Data type: string
Access type: Read-only

 

Fully-qualified path to the service binary file that implements the service.

Example: "/SystemRoot/System32/drivers/afd.sys"

 

ProcessId
Data type: uint32
Access type: Read-only

 

Process identifier of the service.

Example: 324

 

ServiceSpecificExitCode
Data type: uint32
Access type: Read-only

 

Service-specific error code for errors that occur while the service is either starting or stopping. The exit codes are defined by the service represented by this class. This value is only set when the ExitCode property value is ERROR_SERVICE_SPECIFIC_ERROR (1066).

 

ServiceType
Data type: string
Access type: Read-only

 

Type of service provided to calling processes.

Values are:

"Kernel Driver"
"File System Driver"
"Adapter"
"Recognizer Driver"
"Own Process"
"Share Process"
"Interactive Process"

 

Started
Data type: boolean
Access type: Read-only

 

Service has been started.

 

StartMode
Data type: string
Access type: Read-only

 

Start mode of the Windows base service.

ValueMeaning
"Boot"Device driver started by the operating system loader (valid only for driver services).
"System"Device driver started by the operating system initialization process. This value is valid only for driver services.
"Auto"Service to be started automatically by the service control manager during system startup.
"Manual"Service to be started by the service control manager when a process calls the StartService method.
"Disabled"Service that cannot be started.

 

StartName
Data type: string
Access type: Read-only

 

Account name under which a service runs. Depending on the service type, the account name may be in the form of DomainName/Username. The service process is logged by using one of these two forms when it runs. If the account belongs to the built-in domain, then ./Username can be specified. For kernel or system level drivers, StartName contains the driver object name (that is, /FileSystem/Rdr or /Driver/Xns) which the input and output (I/O) system uses to load the device driver. Additionally, if NULL is specified, the driver runs with a default object name created by the I/O system based on the service name.
Example: "DWDOM/Admin"

Windows XP:  You may use UPN format ( Username@DomainName) to specify the StartName.
Windows 2000:  To change from a specified user to the LocalSystem account, use ./LocalSystem.

 

 

State
Data type: string
Access type: Read-only

 

Current state of the base service.

Values are:

"Stopped"
"Start Pending"
"Stop Pending"
"Running"
"Continue Pending"
"Pause Pending"
"Paused"
"Unknown"

 

Status
Data type: string
Access type: Read-only

 

Current status of the object. Various operational and non-operational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard drive, may be functioning properly but predicting a failure in the near future). Non-operational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither "OK" nor in one of the other states.

Values are the following:

"OK"
"Error"
"Degraded"
"Unknown"
"Pred Fail"
"Starting"
"Stopping"
"Service"

 

SystemCreationClassName
Data type: string
Access type: Read-only

 

Type name of the system that hosts this service.

 

SystemName
Data type: string
Access type: Read-only

 

Name of the system that hosts this service.

 

TagId
Data type: uint32
Access type: Read-only

 

Unique tag value for this service in the group. A value of 0 (zero) indicates that the service does not have a tag. A tag can be used to order service startup within a load order group by specifying a tag order vector in the registry located at: HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/GroupOrderList. Tags are only evaluated for Kernel Driver and File System Driver start type services that have Boot or System start modes.

 

WaitHint
Data type: uint32
Access type: Read-only

 

Estimated time required (in milliseconds) for a pending start, stop, pause, or continue operation. After the specified amount of time has elapsed, the service makes its next call to the SetServiceStatus method with either an incremented CheckPoint value or a change in CurrentState. If the amount of time specified by WaitHint passes, and CheckPoint has not been incremented, or CurrentState has not changed, the service control manager or service control program assumes that an error has occurred.

 

 

<think>好的,我需要回答用户关于Windows Management Instrumentation (WMI)的使用指南或示例教程的问题。首先,我需要回顾用户提供的引用内容,看看有哪些相关信息可以利用。用户提供了五个引用链接,涵盖了WMI的简介、攻击向量、编程示例、类集合以及具体的使用命令。 首先,我应该从WMI的基本概念开始介绍,这对应引用[1]和引用[4]。引用[1]提到了WMI的简介和攻击向量,而引用[4]详细说明了WMI类集合的用途。因此,我需要解释WMI是什么,它的主要功能,以及它在系统管理中的作用。 接下来,用户可能需要了解如何使用WMI,特别是编程示例。引用[3]提到了VBA示例,引用[5]给出了PowerShell命令Get-WmiObject Win32_Process的使用。我需要分别展示不同语言中的使用方式,比如PowerShell、VBScript/VBA和C#,这样用户可以有多方面的参考。同时,确保代码示例正确,符合用户提到的LaTeX格式要求,不过代码块应该用反引号包裹,而不是LaTeX的数学表达式。 然后,根据引用[2],WMI控件的配置也是一个重要部分。用户可能需要知道如何访问和配置WMI设置,比如远程连接、安全设置等。这部分需要简明扼要地列出步骤,并引用相关来源。 另外,用户可能对WMI的实际应用场景感兴趣,比如系统监控、远程管理等,这可以结合引用[4]中的类集合来举例说明,如Win32_Process、Win32_Service等类的使用。 在生成相关问题部分,需要涵盖基础概念、具体操作、安全性和实际应用等方面的问题,这样用户可以根据自己的需求进一步探索。例如,如何通过WMI监控系统性能,或者WMI的安全隐患,这些都是用户可能关心的点。 需要注意的是,回答中所有引用的地方要自然添加引用标识,比如在介绍WMI配置时引用[2],在代码示例处引用[3]和[5]。同时,要确保使用中文回答,结构清晰,分步骤说明,并避免使用Markdown格式,保持文本的自然流畅。 最后,检查LaTeX语法是否正确,虽然用户的问题中数学表达式不多,但如果有变量或公式出现,要用$...$或$$...$$包裹。不过当前内容中可能较少涉及数学表达式,主要集中在代码示例和文字描述上。 总结一下,回答的结构应该是: 1. WMI简介(引用[1][4]) 2. 使用方法(PowerShell、VBScript/VBA、C#示例,引用[3][5]) 3. WMI配置(引用[2]) 4. 应用场景(引用[4][5]) 5. 相关问题 确保每个部分都有对应的引用标注,并且语言简洁明了,符合用户的要求。</think>### Windows Management Instrumentation (WMI) 使用指南 #### 1. WMI 简介 Windows Management Instrumentation (WMI) 是 Windows 系统管理的核心工具,提供统一的接口用于查询和操作系统配置、硬件状态、进程信息等数据。它基于 CIM(公共信息模型)标准,通过类(Class)和实例(Instance)描述系统资源,支持本地和远程管理[^1][^4]。 #### 2. 基础使用方法 ##### PowerShell 示例 通过 `Get-WmiObject` 命令可快速获取系统信息。例如,获取当前运行的进程: ```powershell Get-WmiObject Win32_Process | Select Name, ProcessId ``` 此命令返回进程名称和 ID[^5]。 ##### VBScript/VBA 示例 以下代码通过 VBA 查询操作系统版本: ```vb Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem") For Each objItem in colItems MsgBox "OS 版本: " & objItem.Caption Next ``` 此脚本通过 `Win32_OperatingSystem` 类获取系统信息[^3]。 ##### C# 示例 通过 .NET 的 `System.Management` 命名空间访问 WMI: ```csharp using System.Management; var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Service"); foreach (ManagementObject service in searcher.Get()) { Console.WriteLine("服务名称: " + service["Name"]); } ``` 此代码遍历所有系统服务。 #### 3. WMI 配置 通过 **WMI 控件**(`wmimgmt.msc`)可配置本地或远程计算机的 WMI 设置: - **安全设置**:控制用户/组的访问权限。 - **远程连接**:启用防火墙规则(如 DCOM 端口)并配置身份验证模式[^2]。 #### 4. 典型应用场景 - **系统监控**:通过类如 `Win32_Processor`(CPU 状态)、`Win32_DiskDrive`(磁盘信息)实时获取硬件数据。 - **远程管理**:跨网络管理服务(`Win32_Service`)或进程(`Win32_Process`)。 - **自动化脚本**:批量部署软件或配置系统参数[^1]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值