ServiceControl 表ServiceControl Table

ServiceControl 表用于控制已安装或已卸载的服务。The ServiceControl table is used to control installed or uninstalled services.


不能使用ServiceInstall和 ServiceControl 表来安装或启动依赖于全局程序集缓存中的程序集的服务 (GAC) 。Services that rely on the presence of an assembly in the Global Assembly Cache (GAC) cannot be installed or started using the ServiceInstall and ServiceControl tables. 如果需要启动依赖于 GAC 中的程序集的服务,则必须在 InstallFinalize 操作提交自定义操作后使用序列化的自定义操作。If you need to start a service that depends on an assembly in the GAC, you must use a custom action sequenced after the InstallFinalize action or a commit custom action. 有关将程序集安装到 GAC 中的信息,请参见将 程序集安装到全局程序集缓存中。For information about installing assemblies to the GAC see Installation of Assemblies to the Global Assembly Cache.

ServiceControl 表包含以下列。The ServiceControl table has the following columns.

Column 类型Type Key NullableNullable
ServiceControlServiceControl 标识符Identifier YY NN
名称Name Formatted NN NN
事件Event 整数Integer NN NN
参数Arguments Formatted NN YY
WaitWait 整数Integer NN YY
组件_Component_ 标识符Identifier NN NN



这是此表的主键。This is the primary key of this table.


此列是为服务命名的字符串。This column is the string naming the service. 此列可用于控制未安装的服务。This column can be used to control a service that is not installed.


此列包含要对指定服务执行的操作。This column contains the operations to be performed on the named service. 请注意,在停止服务时,所有依赖于该服务的服务也会停止。Note that when stopping a service, all services that depend on that service are also stopped. 删除正在运行的服务时,安装程序将停止此服务。When deleting a service that is running, the installer stops the service.

此字段中的值是位域,可以合并为表示多个操作的单个值。The values in this field are bit fields that can be combined into a single value that represents several operations.

以下值仅在安装过程中使用。The following values are only used during an installation.

常数Constant 十六进制Hexadecimal 小数Decimal 描述Description
msidbServiceControlEventStartmsidbServiceControlEventStart 0x0010x001 11 StartServices 操作期间启动该服务。Starts the service during the StartServices action.
msidbServiceControlEventStopmsidbServiceControlEventStop 为 0x0020x002 22 StopServices 操作过程中停止服务。Stops the service during the StopServices action.
(无)(none) 0x0040x004 44
msidbServiceControlEventDeletemsidbServiceControlEventDelete 0x0080x008 88 DeleteServices 操作期间删除服务。Deletes the service during the DeleteServices action.

以下值仅在卸载过程中使用。The following values are only used during an uninstall.

常数Constant 十六进制Hexadecimal 小数Decimal 描述Description
msidbServiceControlEventUninstallStartmsidbServiceControlEventUninstallStart 0x0100x010 1616 StartServices 操作期间启动该服务。Starts the service during the StartServices action.
msidbServiceControlEventUninstallStopmsidbServiceControlEventUninstallStop 0x0200x020 3232 StopServices 操作过程中停止服务。Stops the service during the StopServices action.
(无)(none) 0x0400x040 6464
msidbServiceControlEventUninstallDeletemsidbServiceControlEventUninstallDelete 0x0800x080 128128 DeleteServices 操作期间删除服务。Deletes the service during the DeleteServices action.


用于启动服务的参数的列表。A list of arguments for starting services. 参数由 null 字符分隔 [ ~ ] 。The arguments are separated by null characters [~]. 例如,一个、两个和三个参数的列表列出为:两个参数中的一个 [ ~ ] [ ~ ] 。For example, the list of arguments One, Two, and Three are listed as: One[~]Two[~]Three.


如果将此字段留空或输入的值为1,则会导致安装程序等待最长30秒以便服务完成,然后再继续。Leaving this field null or entering a value of 1 causes the installer to wait a maximum of 30 seconds for the service to complete before proceeding. 等待时间可用于使严重事件的额外时间返回失败错误。The wait can be used to allow additional time for a critical event to return a failure error. 此字段中的值为0意味着仅等待服务控制管理器 (SCM) 报告此服务处于挂起状态,然后再继续安装。A value of 0 in this field means to wait only until the service control manager (SCM) reports that this service is in a pending state before continuing with the installation.


组件表的第一列的外部键。External key to column one of the Component Table.


序列表中的 StartServicesStopServicesDeleteServices操作处理此表中的信息。The StartServices, StopServices, and DeleteServices actions in sequence tables process the information in this table. 有关使用 序列表 的信息,请参阅 使用序列表For information about using sequence tables, see Using a Sequence Table.

使用 "名称" 列来启动、停止或删除正在被安装或依赖于正在安装的新服务的服务。Use the Name column to start, stop, or delete services that are being replaced by the installation or that are dependent upon a new service that is being installed. 例如,在 ServiceControl 列中输入 MyService 可以将此服务绑定到 "组件" 列中的 MyComponent _ 。For example, entering MyService into the ServiceControl column can tie this service to MyComponent in the Component_ column. 如果在安装时 "事件" 列中的位域设置为 "启动",则安装程序会在安装 MyComponent 时启动 MyService。If the bit field in the Event column is set for start while installing, then the installer starts MyService when installing MyComponent.