Click here to Skip to main content
15,901,284 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: How do I change service startup type Pin
Sunil G11-May-10 23:07
Sunil G11-May-10 23:07 
Hi,

Here is an example to change the startup mode of any service.

using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
    public class CallWMIMethod
    {
        public static void Main()
        {
            try
            {
                ManagementObject classInstance = 
                    new ManagementObject("root\\CIMV2", 
                    "Win32_Service.Name='ALG'",
                    null);

                // Obtain in-parameters for the method
                ManagementBaseObject inParams = 
                    classInstance.GetMethodParameters("ChangeStartMode");

                // Add the input parameters.
                inParams["StartMode"] =  "3";

                // Execute the method and obtain the return values.
                ManagementBaseObject outParams = 
                    classInstance.InvokeMethod("ChangeStartMode", inParams, null);

                // List outParams
                Console.WriteLine("Out parameters:");
                Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
            }
            catch(ManagementException err)
            {
                MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
            }
        }
    }
}



Regards,
Sunil G.
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 
GeneralRe: Maximum number of lines within a class Pin
PIEBALDconsult11-May-10 15:21
mvePIEBALDconsult11-May-10 15:21 

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.