+ Reply to Thread
Results 1 to 2 of 2

Thread: Running a certain service at system_Startup

  1. #1

    Running a certain service at system_Startup

    Hi , i am trying to set a certain service to start at system startup , i used registry , but is there any other way ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    40
    You can do that using the management class , you will need to add a reference to the System.Management, as well as import the namespace System.Management.
    And use the below code :
    Code:
    var service = "<your service name>";
    string objPath = string.Format("Win32_Service.Name='{0}'", service);
    using (var service = new ManagementObject(new ManagementPath(objPath)))
    {
        var result = (int)service.InvokeMethod("ChangeStartMode", new object[] {"Automatic"});
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts