以编程方式安装Windows消息队列

时间:2012-10-12 15:53:28

标签: c# message-queue silent-installer

我的应用程序需要Windows功能

enter image description here

待安装。

我目前使用this solution查看是否已安装。

现在,一旦我知道它没有运行,我将如何安装它。我试过了:

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                          
}   

1 个答案:

答案 0 :(得分:1)

<强>声明

我不会尝试从代码中安装它;相反,我会将消息队列作为您的应用程序的先决条件,并在安装应用程序时安装它。


我不知道您是否可以使用C#进行此操作,但这里有关于执行无人参与安装的文章。您可以构建命令行来执行安装。

Server 2003 / Windows XP:http://technet.microsoft.com/en-us/library/cc778216(v=ws.10).aspx

Server 2008 / Windows 7:http://technet.microsoft.com/en-us/library/cc731283(v=ws.10).aspx

相关问题