Not able to start a windows service from a program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramaswamynanda
    New Member
    • Jul 2007
    • 32

    Not able to start a windows service from a program

    Hello,

    I have written a windows service , S1 , that is scheduled to run daily. It reads some files and updates the database. It works well .

    A requirement has arisen to call this service from a report program, as the report needs to see the latest data being updated by this service.

    This is the code i am using.
    Code:
    		ServiceController controller  = new ServiceController();
    			controller.ServiceName = "S1";
    			
    			//controller
    			try
    			{
    				controller.Start();
    			}
    			catch(Exception e)
    		{Response.Write(e.Message + " , " + e.StackTrace);}
    The error is get is cannot start service S1 from machine "."

    I tried configuring service bpth for localsystem and localservice accounts, but both dont work


    Please help me,

    Thanks and regards
    nanda
    Last edited by Plater; Mar 4 '08, 09:11 PM. Reason: added CODE tags
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Can you go to to the services window and click start?
    Or start it from the command line with "NET START <servicename> "?

    Comment

    • MedIt
      New Member
      • Feb 2008
      • 15

      #3
      It is worth checking if you are using the correct service name, and as sometimes the service name and the display are different.

      Comment

      Working...