0

Is there a way to find out if rabbitmq is installed on the machine?

Either a command line or powershell script or something in C# because I am trying to check it in my c# code.

I searched for it and found only this one, but it did not help much for my case

Verify version of rabbitmq

EDIT

Just found this code snippet in one of the answers of the above post, but not sure it is the right way

public string GetRabbitMqVersion()
{
    string prefix = "rabbitmq_server-";
    var dirs = System.IO.Directory.EnumerateDirectories(@"C:\Program Files (x86)\RabbitMQ Server", string.Format("{0}*",prefix));

    foreach (var dir in dirs)
    {
        //Just grab the text after 'rabbitmq_server-' and return the first item found
        var i = dir.LastIndexOf(prefix);
        return dir.Substring(i+16);
    }
    return "Unknown";
}
Compo
  • 36,585
  • 5
  • 27
  • 39
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105
  • Anyone using this on Windows should be defining several environment variables, so to find out if it is installed, *or I suppose, has been installed before*, the quickest way would probably be to check to see if one or more of those variables have been defined. For example `Set RABBITMQ_ >NUL && Echo RabbitMQ variables are defined.`. Alternatively you could check within the users Roaming profile directory`If Exist "%APPDATA%\RabbitMQ\" Echo Found profile directory.`, or its contents, for example the main config file, `If Exist "%APPDATA%\RabbitMQ\rabbitmq.conf" Echo Found main config file.`. – Compo Jan 15 '21 at 14:28

2 Answers2

1

As the documentation says you should have a directory with the file rabbitmqctl.bat

The file should be placed on C:\Program Files\RabbitMQ\rabbitmq_server-x.x.x\sbin\

Then you can run any command in a cmd like this rabbitmq-service.bat status

https://www.rabbitmq.com/install-windows-manual.html

  • What about `C:\Program Files (x86)\RabbitMQ\rabbitmq_server-x.x.x\sbin\ `? – Compo Jan 15 '21 at 14:33
  • This path should be the path where you've installed the rabbitmq. – omeninocloud Jan 15 '21 at 17:12
  • omeninocloud, if the OP knew where the end user had installed it, they wouldn't be asking if there was a way of finding out if it was installed; they would already know. Even if the software was installed in the default location, depending upon the bitness of the software and/or OS, that could be in either `Program Files` or `Program Files (x86)`. Also the end user could probably, regardless of whether they are using the Windows installer, or Chocolatey, or manual methods, choose an alternative installation directory anywhere else. – Compo Jan 15 '21 at 17:40
0

A list of installed software is available. What is the name of the RabbitMQ app in this list? Once this is known, it is easy to identify.

powershell -NoLogo -NoProfile -Command ^
    "Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |" ^
        "Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |" ^
        "Sort-Object -Property DisplayName"
lit
  • 14,456
  • 10
  • 65
  • 119
  • That looks like a working solution! I do get the list of programs installed. But I am not that thorough in powershell, could you please tell me how can I filter the records to get only rabbitmq? – Pawan Nogariya Jan 16 '21 at 17:14
  • Okay, I could manage to create the working solution from your answer, please let me know if the solution is fine `(Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object{$_.DisplayName -like '*rabbitmq server*'} | Select-Object) -eq $null` – Pawan Nogariya Jan 16 '21 at 17:40
  • 1
    Yes, I think you have it. – lit Jan 16 '21 at 23:01