简体   繁体   English

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

[英]TFS Build Workflow - InvokeProcess for SC.EXE? Or Custom Activity?

I need to run a command as part of my build workflow.我需要在构建工作流程中运行一个命令。 Specifically, it is sc.exe with certain parameters like this:具体来说,它是带有某些参数的 sc.exe,如下所示:

sc.exe \\computerName STOP "serviceName"

In the build workflow, can I just use InvokeProcess activity to do this?在构建工作流程中,我可以只使用 InvokeProcess 活动来执行此操作吗? I want to avoid batch files.我想避免批处理文件。 Should I use InvokeProcess, and if so, do i have to provide the path to SC.exe.我应该使用 InvokeProcess,如果是,我是否必须提供 SC.exe 的路径。 I would not think so because it's path is recognized no matter the working directory (i think because its a windows system executable).我不这么认为,因为无论工作目录如何,它的路径都可以识别(我认为是因为它是 windows 系统可执行文件)。

Or should I do this another way?或者我应该以另一种方式做到这一点?

You should be able to use the InvokeProcess activity.您应该能够使用InvokeProcess活动。 Set the FileName property to "sc.exe" and Arguments toFileName属性设置为“sc.exe”并将Arguments设置为

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

Assuming there are variables named ComputerName and ServiceName in scope.假设 scope 中有名为 ComputerName 和 ServiceName 的变量。

You should set the FileName property to "cmd.exe" and then set Arguments to "/c sc.exe \\computerName STOP " + ServiceName您应该将 FileName 属性设置为“cmd.exe”,然后将 Arguments 设置为“/c sc.exe \\computerName STOP”+ ServiceName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM