使用服务的实例存在于Microsoft.Sdc.Tasks MSBuild任务?实例、任务、Microsoft、Sdc

2023-09-04 05:39:17 作者:因自太帥、沒人敢愛

我试图使用 Microsoft.Sdc.Tasks.ServiceProcess.Exists 来检查服务是否存在。还有,虽然使用它的文档中没有例子。任何人有一个?

I'm trying to use the Microsoft.Sdc.Tasks.ServiceProcess.Exists to check whether or not a service exists. There is no example of using it in the documentation though. Anyone have one?

推荐答案

我还没有实际使用该生产我自己,我不知道您的版本(我有2.1.3155.0版本的副本),并根据所附的.chm帮助文件的任务具有以下属性:

I've not actually used this in production myself, and I'm not sure which version you have (I have a copy of Release 2.1.3155.0) and according to the accompanying .chm help file the Task has the following properties:

DoesExist返回true,如果指定的服务存在 IsDisabled如果该服务被禁用,则返回TRUE 在服务名称标识服务系统的简称。

的服务名称需要被设置为标识的服务给系统,例如'W3SVC'短名称。

The ServiceName needs to be set to "The short name that identifies the service to the system, e.g. 'W3SVC'".

您可能想给它一个知名的服务一试(如MSSQLSERVER),并检查其它两个属性的结果(DoesExist / IsDisabled)。

You might want to give it a try with a well known service (e.g. mssqlserver) and check the result of the other two properties (DoesExist/IsDisabled).

更新:下面是一个示例(工程):

Update: Here's a sample (works):

导入任务,然后调用(例如)

Import the tasks, then call (e.g.)

< Microsoft.Sdc.Tasks.ServiceProcess.Exists        服务名称=服务器>       <输出TaskParameter =DoesExist属性名=存在/> < /Microsoft.Sdc.Tasks.ServiceProcess.Exists>

< Microsoft.Sdc.Tasks.ServiceProcess.Exists ServiceName="Server"> < Output TaskParameter="DoesExist" PropertyName="Exists" /> < /Microsoft.Sdc.Tasks.ServiceProcess.Exists >

&LT;消息文本=服务存在?$(存在)/>

< Message Text="Service exists? $(Exists)" />