TFS build workflow - InvokeProcess for SC.EXE? Or user activity?

I need to run a command as part of my build workflow. In particular, it is sc.exe with parameters such as this:

sc.exe \\computerName STOP "serviceName" 

In the build workflow, can I just use the InvokeProcess operation to do this? I want to avoid batch files. Should I use InvokeProcess, and if so, should I provide the path to SC.exe. I would not think so, because this path is recognized regardless of the working directory (I think because its Windows executable).

Or should I do it another way?

+4
source share
2 answers

You should be able to use InvokeProcess . Set the FileName property to "sc.exe" and Arguments in

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

Assuming there are variables in the scope named ComputerName and ServiceName.

+6
source

You must set the FileName property to "cmd.exe" and then set the Arguments to "/ c sc.exe \\ STOP ComputerName" + ServiceName

+2
source

All Articles