I have been working on the following issue since a week. If anybody help me to come out of this issue this is really really really a great and big help.
I developed a windows service. When I install it, it should check the check box "Allow service to interact with desktop" in the Logon tab of the properties of the windows servic and then it should start the service automatically. It is doing it fine with my code. But it is not giving me the required output.
It is giving me required output, when I did it manually(Check the check box) and start the service.
Thank you very much,
//for installation mode and service startup type
_service = new ServiceInstaller();
_service.ServiceName = strServiceName;
_service.StartType = ServiceStartMode.Automatic;
_service.Description = "Communicates between Client and Server with acknowledgement on both sides";
_serviceProcess = new ServiceProcessInstaller();
_serviceProcess.Account = ServiceAccount.LocalSystem;
//part2: code to automate the check box "Allow service to interact with desktop"
RegistryKey ckey = Registry.LocalMachine.OpenSubKey(
if (ckey != null)
// Make sure the "Type" value is there,
//and then do bitwise operation on it.
if (ckey.GetValue("Type") != null)
ckey.SetValue("Type", ((int)ckey.GetValue("Type") | 256));
//part3: code to start the service
var controller = new ServiceController(strServiceName);
Case1: If I don't have part2 and part3, then I need to manually check the check box of "alllow to interact with desktop" and then start the service. In this case I am able to get my required output (able to display Form on desktop.)
Case2: If I include part2 and part3, it is installing, checking the check box and running the service fine.
But I am unable to get my required output(form on desktop) in this case.