TFS构建工作流 - SC.EXE的InvokeProcess?还是自定义活动?

时间:2011-08-11 14:47:25

标签: c# .net tfs tfs2010 build-automation

我需要在构建工作流程中运行命令。具体来说,它是sc.exe,具有如下所示的某些参数:

sc.exe \\computerName STOP "serviceName"

在构建工作流程中,我可以使用InvokeProcess活动来执行此操作吗?我想避免批处理文件。我应该使用InvokeProcess,如果是这样,我是否必须提供SC.exe的路径。我不这么认为,因为它的路径无论工作目录是否被识别(我认为因为它是一个Windows系统可执行文件)。

或者我应该采取另一种方式吗?

2 个答案:

答案 0 :(得分:7)

您应该可以使用InvokeProcess活动。将FileName属性设置为“sc.exe”,将Arguments设置为

String.Format("\\{0} STOP ""{1}""", ComputerName, ServiceName)

假设在范围内有名为ComputerName和ServiceName的变量。

答案 1 :(得分:2)

您应该将FileName属性设置为“cmd.exe”,然后将Arguments设置为 “/ c sc.exe \\ computerName STOP”+ ServiceName