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?
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.
You should set the FileName property to "cmd.exe" and then set Arguments to "/c sc.exe \\computerName STOP " + ServiceName
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.