我的应用程序需要 Windows 功能
要安装。
我目前使用这个解决方案来查看它是否已安装。
现在,一旦我知道它没有运行,我将如何安装它。我试过了:
List<ServiceController> services = ServiceController.GetServices( ).ToList( );
ServiceController msQue = services.Find( o => o.ServiceName == "MSMQ" );
if ( msQue != null )
{
if ( msQue.Status == ServiceControllerStatus.Running )
{
Console.Write( "it is running" );
return;
}
}
else
{
Console.WriteLine( "It is not running \n\nPress enter to install" );
Console.Read( );
msQue.Start( ); // <- I was hoping to look for a method that will turn feature on or off
}