Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 \\computerName STOP "serviceName"

In the build workflow, can I just use InvokeProcess activity to do this? I want to avoid batch files. Should I use InvokeProcess, and if so, do i have to provide the path to 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).

Or should I do this another way?

like image 562
Issa Fram Avatar asked Jan 19 '23 00:01

Issa Fram


1 Answers

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

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

Assuming there are variables named ComputerName and ServiceName in scope.

like image 93
vcsjones Avatar answered Feb 02 '23 11:02

vcsjones