Windows Service Install

  • Thread starter Thread starter RajkiranPro
  • Start date Start date
R

RajkiranPro

i created a windows service and created a installer for it..

i just want to add a feature to it.. please guide me in doin that..

the serviceprocessinstaller allows me to specify the account type as
the Local System account..

However i want enable the option Allow Service To Interact With The
desktop while the installer installs insted of manually enabling the
option...

is that possible"

Thanks in Advance

Rajkiran
 
The proper way of setting that value isn't from modifying the registry
directly, it's using the Service Control Manager (SCM) to open the service
and modify the configuration using the APIs Microsoft has created.
Specifically the ChangeServiceConfig function. If you are doing this on
Vista you will need to ensure you elevate the privileges of the user before
you open the SCM otherwise you will not get a valid handle to use.

http://msdn.microsoft.com/en-us/library/ms681987(VS.85).aspx

The suggested way of doing this is within your Installer that you've placed
within your application, override the OnCommit method (ensuring that you
allow it to call base.OnCommit) and calling the function from within there.

Here is a link to the ChangeServiceConfig function on pinvoke.net if you
aren't sure how to handle the interop yourself.

http://pinvoke.net/default.aspx/advapi32.ChangeServiceConfig
 
I would not recommend doing this as it is not supported in Vista, nor
likely in any further operating systems.

Actually, this feature is still supported in Vista. Microsoft chose to not
implement all the functionality of the ChangeServiceConfig and
ChangeServiceConfig2 API functions in the .NET Framework. If you want more
advanced functionality than what is provided out of the box with .NET you
have to do the interop yourself.
 
Back
Top