Ahsan Ahsan - 1 month ago 16
C# Question

How to enable MSMQ programatically in C#?

I have a server with a request queue and a client with a responsive queue.
I want to install MSMQ pragmatically on client as well as on server machine i.e. not by manually going to Server Manager/Add window's features. Please help in this regard.

Answer

You can start

dism.exe /Online /Enable-Feature /FeatureName:MSMQ-Server /all  

as a process using:

System.Diagnostics.Process.Start()

If you need any aditionally Msmq features, you can find list this by doing:

dism.exe /online /get-features | Find "MSMQ"

which gives you something like:

Feature Name : MSMQ-Container
Feature Name : MSMQ-Server
Feature Name : MSMQ-Triggers
Feature Name : MSMQ-ADIntegration
Feature Name : MSMQ-HTTP
Feature Name : MSMQ-Multicast
Feature Name : MSMQ-DCOMProxy
Feature Name : WCF-MSMQ-Activation45