ServiceController .net c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MedIt
    New Member
    • Feb 2008
    • 15

    ServiceController .net c#

    Hi all,

    I am trying to controll a service programatically using the ServiceControll er class .net c#.
    It is giving me an error that it cannot find the service name.

    I have tried it stopping with the command line using NET, and it works but not with my code!
    Can anyone please point me where I might be wrong?

    My code:
    string SERVICENAME = "TestServic e";
    string SERVERNAME = "ABC" ;
    ServiceControll er myController = new ServiceControll er();
    myController.Ma chineName = SERVERNAME;
    myController.Se rviceName = SERVICENAME;
    myController.St op();
    myController.St art();

    my commandline goes something like this:
    C:\test>NET STOP "TestServic e"

    and it works.
    I have tried without the machine name, and also with my IP address both failed!

    The exact error is something like:
    "Cannot open TestService service on computer 'ABC'." "

    Thanks in advance!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Sounds like remote access to services are not allowed?

    Comment

    • MedIt
      New Member
      • Feb 2008
      • 15

      #3
      This has been resolved.Appare ntly the service display name and the service name was different.
      Thanks for your response though!
      Originally posted by Plater
      Sounds like remote access to services are not allowed?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I had thought of that, but wasn't sure it was even possible as I couldn't think of a service with a different display name vs service name offhand.
        Glad you found the solution.

        Comment

        Working...