in Education by
I need to change the credentials of an already existing Windows service using C#. I am aware of two different ways of doing this. ChangeServiceConfig, see ChangeServiceConfig on pinvoke.net ManagementObject.InvokeMethod using Change as the method name. Neither seems a very "friendly" way of doing this and I was wondering if I am missing another and better way to do this. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Here is one quick and dirty method using the System.Management classes. using System; using System.Collections.Generic; using System.Text; using System.Management; namespace ServiceTest { class Program { static void Main(string[] args) { string theServiceName = "My Windows Service"; string objectPath = string.Format("Win32_Service.Name='{0}'", theServiceName); using (ManagementObject mngService = new ManagementObject(new ManagementPath(objectPath))) { object[] wmiParameters = new object[11]; wmiParameters[6] = @"domain\username"; wmiParameters[7] = "password"; mngService.InvokeMethod("Change", wmiParameters); } } } }

Related questions

0 votes
    I need to change the credentials of an already existing Windows service using C#. I am aware of two ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    App needs to run on the .Net Compact Framework v.3.5. Video can be any format, but I do need ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    Is there an easier way to step through the code than to start the service through the Windows Service ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Is there an easier way to step through the code than to start the service through the Windows Service ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Is there an easier way to step through the code than to start the service through the Windows Service ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Is there an easier way to step through the code than to start the service through the Windows Service ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have a user interface in .net which needs to receive data from a server, on a request/reply/ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    An unhandled exception of type System.AggregateException occurred in mscorlib.dll Inner Exception: {"Response status ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I have a pdf template file that contains one form field. I want to fill out and flatten this form ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    __________ is the best way for communicating the results of data analysis using the R language. (a) Single ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    A windows which menu contains the sizing option which enable you to change the window size easily Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    You can change the colour scheme of the Start menu and other windows. in Windows 7. There are mini programs ... to the Recycle Bin Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    If you change Windows 98 operating system to Windows XP, then it is known as- (a) Update (b) Patch (c) Pull ... ) Push up (e) Upgrade Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    If I am trying to determine the read speed of a drive, I can code a routine to write files to a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
...