Windows Service - Desktop Interaction

R

rajkiranpro

I created a windows service in C# and I want to enable desktop interaction..

I can do this manually by going to the service properties and clicking on
the log on tab and checking allow user desktop interaction

however I want to do his while installing the service itself..

is there anyway I can do this by using the serviceinstaller or
serviceprocessinstaller??

Thanks


Regards
Rajkiran
 
K

Kerem Gümrükcü

Hi Rajkiran,

inherit from the Class that installs the Service and then
set the specific flag on successfull install by your own
into the registry. That simple. The Property you have
to change is the "Type" DWORD Property for the
Service in the registry. For Example, if you have the
Service named "MyService", then you have to look
for the "Type" Property of it, that can be found under:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService

The Final Service Type Property in the registry must be OR'ed (|) with
SERVICE_INTERACTIVE_PROCESS =0x00000100;

Regards

Kerem


Regards

Kerem
 
R

rajkiranpro

Thank You for the reply,
I had this code in the afterinstall event of the service process installer.
however after installing the desktop interaction wasn't enabled.

try
{
RegistryKey ckey =
Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\FMonService",
true);
// Good to always do error checking!

if (ckey != null)
{
// Ok now lets make sure the "Type" value is there,

//and then do our bitwise operation on it.

if (ckey.GetValue("Type") != null)
{
ckey.SetValue("Type", ((int)ckey.GetValue("Type") |
256));
}
}
}
catch
{

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top