G
Guest
hi all,
as it was discussed earlier in this forum titled,"Execution of Another
Application in Services", i got the answer that Services are not meant for
executing another applications, but Microsoft has given the options to
Interact with Desktop for the Services which need to...
I got many C Service Programs wherein they execute another application
depending upon the need...when i asked how can it be done in C#, many said it
should not be done but didnt give any suggestions on how to implement it...
When i was searching for this stuff, i found that enabling Interaction of
Desktop was a common thing and we can use it whenever we need to..and i got
this code from www.codeproject.com which is working fine...
the code s as follows,
/*********************code starts here**************************/
private void ServiceInstaller_AfterInstall(object sender,
System.Configuration.Install.InstallEventArgs e)
{
ConnectionOptions coOptions = new ConnectionOptions();
coOptions.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope mgmtScope = new
System.Management.ManagementScope(@"root\CIMV2", coOptions);
mgmtScope.Connect();
ManagementObject wmiService;
wmiService = new ManagementObject("Win32_Service.Name='Service1'");//
+ServiceController.ServiceName + "'");
ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");
InParam["DesktopInteract"] = true;
ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam,
null);
}
/*********************code ends here**************************/
am not telling that what others told me is wrong, but we have to use
Interact With Desktop option when it is needed and many of the services
running are using it....
so enjoy this stuff...
with regards,
C.C.Chakkaradeep
as it was discussed earlier in this forum titled,"Execution of Another
Application in Services", i got the answer that Services are not meant for
executing another applications, but Microsoft has given the options to
Interact with Desktop for the Services which need to...
I got many C Service Programs wherein they execute another application
depending upon the need...when i asked how can it be done in C#, many said it
should not be done but didnt give any suggestions on how to implement it...
When i was searching for this stuff, i found that enabling Interaction of
Desktop was a common thing and we can use it whenever we need to..and i got
this code from www.codeproject.com which is working fine...
the code s as follows,
/*********************code starts here**************************/
private void ServiceInstaller_AfterInstall(object sender,
System.Configuration.Install.InstallEventArgs e)
{
ConnectionOptions coOptions = new ConnectionOptions();
coOptions.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope mgmtScope = new
System.Management.ManagementScope(@"root\CIMV2", coOptions);
mgmtScope.Connect();
ManagementObject wmiService;
wmiService = new ManagementObject("Win32_Service.Name='Service1'");//
+ServiceController.ServiceName + "'");
ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");
InParam["DesktopInteract"] = true;
ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam,
null);
}
/*********************code ends here**************************/
am not telling that what others told me is wrong, but we have to use
Interact With Desktop option when it is needed and many of the services
running are using it....
so enjoy this stuff...
with regards,
C.C.Chakkaradeep