PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

Can service login properties be modified programmatically AFTER installation?

 
 
Jeff
Guest
Posts: n/a
 
      10th Nov 2005
Is there a way to programmatically modify the "Log on as" property for
an existing Windows service? I can see the ServiceController class can
be used to start/stop the service. I don't see any classes that appear
to give access into the properties however.

Anyone have any ideas?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UnlhbkxlZVNjaG5laWRlcg==?=
Guest
Posts: n/a
 
      10th Nov 2005
You could use the WMI namespace to modify settings on a service.

For example, I have a test service that needs to have "Interact With
Desktop" checked, so I use the following code (which I got from a thread on a
CodeProject article) in my Installer Custom Action:

if (System.Environment.OSVersion.Platform == System.PlatformID.Win32NT)
{
ConnectionOptions coOptions = new ConnectionOptions();

coOptions.Impersonation = ImpersonationLevel.Impersonate;

ManagementScope mgmtScope = new
System.Management.ManagementScope(@"root\CIMV2", coOptions);

mgmtScope.Connect();

ManagementObject wmiService;

wmiService = new ManagementObject("Win32_Service.Name='" +
this.serviceInstaller1.ServiceName + "'");

ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");

InParam["DesktopInteract"] = true;

ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam,
null);
}


I'm sure there's probally something like "LogonUser", "LogonDomain",
"LogonPassword" in there as well.

Or if it's a service you're installing, you can use a ServiceInstaller
object to set all this up for you. Search MSDN for a howto.

"Jeff" wrote:

> Is there a way to programmatically modify the "Log on as" property for
> an existing Windows service? I can see the ServiceController class can
> be used to start/stop the service. I don't see any classes that appear
> to give access into the properties however.
>
> Anyone have any ideas?
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Last modified by login Kashyap Microsoft Outlook Form Programming 1 7th Apr 2009 03:50 PM
Login control missing some properties in the properties pane Adam M Microsoft ASP .NET 1 23rd Jan 2008 10:06 PM
setting If-Modified-Since programmatically Sam Carleton Microsoft ASP .NET 4 4th Jul 2006 10:48 PM
Properties returning a class that need to be modified Tristan Microsoft C# .NET 0 5th Feb 2004 12:24 PM
Automatically installing Fax service programmatically from an installation program Robert Freas Microsoft Windows 2000 Fax 2 22nd Oct 2003 10:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:58 AM.