Results 1 to 4 of 4

Thread: [2005] Change Service Startup Type

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    [2005] Change Service Startup Type

    I want to be able to get & change the startup type for a service through a Windows Application... (Automatic, Manual, Disabled)... Is there a simple way to do this? I didn't see anything using the ServiceController.... I found another thread to use a vbscript but rather do it directly through my application.

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2005] Change Service Startup Type

    You can use the ServiceController component, one second I will dig out the exact code
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2005] Change Service Startup Type

    Actually, my bad, you cant do it through the ServiceController. The way I have done it in the past is to use the built in program in windows named SC.EXE (ie just calling that from Process.Start with certain arguments)
    However, if anyone has an all .NET way of doing it I would be interested to see it
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Change Service Startup Type

    The startup type for a service is stored in the Registry, in the Start value under the "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\ServiceNameHere" key. You can use the My.Computer.Registry.GetValue and SetValue to manipulate it. The value is an integer:

    2 = Automatic
    3 = Manual
    4 = Disabled
    Last edited by jmcilhinney; Feb 5th, 2009 at 12:29 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width