I would like to remotely start or stop the Windows service on another machine using MSBuild. For 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 this on a machine that can see Box2, I get the following:
Project "C: \ Scripts \ Test.xml" on node 1 (default targets).
C: \ Scripts \ Test.xml (4,5): error: Could not find "MyService" service on "Box2" Done Building Project
"C: \ Scripts \ Test.xml" (default goals) - FAILED.
I know that I have the correct service name (I copied and pasted it from the actual list of services), and I'm sure that it can see Box2, because if I change it to a machine name that does not exist (for example, Box2asdf) , it takes about 10 seconds to return (with the same error, mind you), unlike the almost immediate response that I get when I provide the correct machine name.
How can I debug this problem?
source
share