c# - How to set "interact with desktop" in windows service installer -
moving to me under a windows service system account and execute a program from time to time ( Yes, yes, I know that this is a bad practice, but this is not my decision ). After the service is established, to see the GUI of the programs I have to execute, I have to set the "Talk to Desktop" check. I many ways tried the code below to put in AfterInstall or OnCommited event handler of your service installer: or If you set both of these methods "work" are Czech, but when I service launched If I stop the service, I'll check again and start again - bingo! Everything starts and is shown another way of getting results. reboot is - is shown lowing after it. so the question is: is there a way to check to interact with "desktop", will start by re-check and reboot Without a In doing? OS: Windows XP (Vista and 7 have not tried ...)
Knekshnopshn cooptions = new connectionOptions (); CoOptions.Imersonation = impersonationLevel.Impersonate; Management scope mgmtScope = new system.Management. ManagementScope (@ "Root \ CIMV2", Cooption); MgmtScope.Connect (); Mandnobjekt wmiService = new Mandnobjekt ( "Win32_Service.Name = '" + ServiceMonitorInstaller.ServiceName + "' '); ManagementBaseObject InParam = wmiService.GetMethodParameters (" Change "); Inparam [" Desktop Intrtekt "] = true; ManagementBaseObject Autparam = wmiService. Change InvokeMethod ( "", InParam, null);
Rjistryki ckey = registry.LocalMachine.OpenSubKey (@ "system \ CurrentControlSet \ Services \ WindowsService1 ", true); if (ckey! = Null) {if (ckey.GetValue (" Type ")! = Null} {ckey.SetValue (" Type ", ((int) ckey.GetValue (" Type ") | 256));}}
Comments
Post a Comment