Click here to Skip to main content
15,905,071 members
Home / Discussions / C#
   

C#

 
QuestionHow do I change service startup type Pin
ziopino7011-May-10 6:25
ziopino7011-May-10 6:25 
AnswerRe: How do I change service startup type Pin
#realJSOP11-May-10 6:30
professional#realJSOP11-May-10 6:30 
GeneralRe: How do I change service startup type Pin
ziopino7011-May-10 6:59
ziopino7011-May-10 6:59 
GeneralRe: How do I change service startup type Pin
PIEBALDconsult11-May-10 7:50
mvePIEBALDconsult11-May-10 7:50 
GeneralRe: How do I change service startup type Pin
Luc Pattyn11-May-10 7:54
sitebuilderLuc Pattyn11-May-10 7:54 
AnswerRe: How do I change service startup type Pin
Dimitri Witkowski11-May-10 10:01
Dimitri Witkowski11-May-10 10:01 
GeneralRe: How do I change service startup type Pin
Sunil G11-May-10 22:27
Sunil G11-May-10 22:27 
AnswerRe: How do I change service startup type Pin
Pete O'Hanlon11-May-10 22:44
mvePete O'Hanlon11-May-10 22:44 
I wouldn't use the registry to accomplish this. You could always look to use WMI to accomplish this. Here's a sample that might help (I knocked it up in Notepad, so I apologise if the syntax isn't 100% correct):
public enum StartupType
{
  Automatic,
  Disabled, 
  Manual
}

public void SetStartupType(string serviceName, StartupType startupType)
{
  string type = startupType.ToString();
  using (ManagementPath mp = new ManagementPath(string.Format("Win32_Service.Name='{0}'", serviceName)))
  {
    if (mp != null)
    {
      using (ManagementObject mo = new ManagementObject(mp))
      {
        object[] parameters = new object[1] { type };
        ManagementObject.InvokeMethod("ChangeStartMode", parameters);
      }
    }
  }
}

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



AnswerRe: How do I change service startup type Pin
Sunil G11-May-10 23:07
Sunil G11-May-10 23:07 
QuestionWindowStartPosition Pin
gmhanna11-May-10 5:32
gmhanna11-May-10 5:32 
AnswerRe: WindowStartPosition Pin
William Winner11-May-10 5:55
William Winner11-May-10 5:55 
AnswerRe: WindowStartPosition Pin
Luc Pattyn11-May-10 6:17
sitebuilderLuc Pattyn11-May-10 6:17 
QuestionCTRL/I within a RichTextBox Pin
gmhanna11-May-10 5:22
gmhanna11-May-10 5:22 
AnswerRe: CTRL/I within a RichTextBox [modified] Pin
William Winner11-May-10 6:00
William Winner11-May-10 6:00 
GeneralRe: CTRL/I within a RichTextBox Pin
gmhanna11-May-10 8:34
gmhanna11-May-10 8:34 
GeneralRe: CTRL/I within a RichTextBox Pin
William Winner11-May-10 9:01
William Winner11-May-10 9:01 
GeneralRe: CTRL/I within a RichTextBox Pin
gmhanna11-May-10 9:20
gmhanna11-May-10 9:20 
AnswerRe: CTRL/I within a RichTextBox Pin
Luc Pattyn11-May-10 6:19
sitebuilderLuc Pattyn11-May-10 6:19 
QuestionSet page range in PrintPreview Pin
baranils11-May-10 5:18
baranils11-May-10 5:18 
QuestionMaximum number of lines within a class Pin
Tony Pazzard11-May-10 4:44
Tony Pazzard11-May-10 4:44 
AnswerRe: Maximum number of lines within a class Pin
Luc Pattyn11-May-10 4:50
sitebuilderLuc Pattyn11-May-10 4:50 
AnswerRe: Maximum number of lines within a class Pin
#realJSOP11-May-10 6:36
professional#realJSOP11-May-10 6:36 
AnswerRe: Maximum number of lines within a class Pin
The Man from U.N.C.L.E.11-May-10 7:42
The Man from U.N.C.L.E.11-May-10 7:42 
AnswerRe: Maximum number of lines within a class Pin
PIEBALDconsult11-May-10 7:51
mvePIEBALDconsult11-May-10 7:51 
GeneralRe: Maximum number of lines within a class Pin
Luc Pattyn11-May-10 7:58
sitebuilderLuc Pattyn11-May-10 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.