【问题标题】:Install Windows Message Queuing programmatically以编程方式安装 Windows 消息队列
【发布时间】:2012-10-03 11:45:29
【问题描述】:

我的应用程序需要 Windows 功能

待安装。

我目前使用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                          
}   

【问题讨论】:

  • 已安装与当前未运行与尚未安装之间存在很大差异。如果尚未安装,则没有开/关。 MSMQ 是一个可选的 Windows 功能,在 Windows 的默认安装中根本没有安装。恐怕您唯一能做的就是让用户知道他们需要让 IT 人员安装 MSMQ 才能运行应用程序。如果它已安装且当前未运行,您可以使用 ServiceController 类来启动它。

标签: c# message-queue silent-installer


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 2012-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多