I'd like to remotely start or stop a windows service on another machine using MSBuild. To accomplish this, I wrote this script:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> <Target Name="MyTarget"> <ServiceController MachineName="Box2" ServiceName="MyService" Action="Stop" /> </Target> </Project> When I run that on a machine that can see Box2, I get this:
Project "C:\Scripts\Test.xml" on node 1 (default targets).
C:\Scripts\Test.xml(4,5): error : Couldn't find the 'MyService' service on 'Box2' Done Building Project
"C:\Scripts\Test.xml" (default targets) -- FAILED.
I know that I have the service name correct (I copied and pasted it from the actual service list), and I'm pretty sure that it can see Box2 because if I change it to a machine name that doesn't exist (e.g. Box2asdf), it takes about 10 seconds to come back (with the exact same error, mind you), as opposed to the nearly immediate response that I get when I provide the correct machine name.
How might I debug this issue?