c# - How to set "interact with desktop" in windows service installer -


itemprop = "text">

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:

  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);  

or

  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));}}  

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 ...)

Private Static Zero SetInternetView Desktop () {var Service = New System. Management. Management object (string format ("WIN32_Service.Name = '{0}'", "YourServiceName")); Try {var paramList = new object [11]; Paralistic [5] = true; Service.InvokeMethod ("Change", Parallax); } Finally {service.Dispose (); }}

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -