4343using System ;
4444using System . Collections . Generic ;
4545using System . Diagnostics ;
46+ using System . IO ;
4647using System . Linq ;
4748using System . Text ;
4849using System . Text . RegularExpressions ;
@@ -417,7 +418,6 @@ internal Process ExecRabbitMQCtl(string args)
417418 {
418419 // Allow the path to the rabbitmqctl.bat to be set per machine
419420 string envVariable = Environment . GetEnvironmentVariable ( "RABBITMQ_RABBITMQCTL_PATH" ) ;
420-
421421 string rabbitmqctlPath ;
422422
423423 if ( envVariable != null )
@@ -428,19 +428,31 @@ internal Process ExecRabbitMQCtl(string args)
428428 if ( match . Success )
429429 {
430430 return ExecRabbitMqCtlUsingDocker ( args , match . Groups [ "dockerMachine" ] . Value ) ;
431- }
432- else
433- {
431+ } else {
434432 rabbitmqctlPath = envVariable ;
435433 }
436434 }
437- else if ( IsRunningOnMonoOrDotNetCore ( ) )
438- {
439- rabbitmqctlPath = "../../../../../../rabbit/scripts/rabbitmqctl" ;
440- }
441435 else
442436 {
443- rabbitmqctlPath = @"..\..\..\..\..\..\rabbit\scripts\rabbitmqctl.bat" ;
437+ // provided by the umbrella
438+ string umbrellaRabbitmqctlPath ;
439+ // provided in PATH by a RabbitMQ installation
440+ string providedRabbitmqctlPath ;
441+
442+ if ( IsRunningOnMonoOrDotNetCore ( ) )
443+ {
444+ umbrellaRabbitmqctlPath = "../../../../../../rabbit/scripts/rabbitmqctl" ;
445+ providedRabbitmqctlPath = "rabbitmqctl" ;
446+ } else {
447+ umbrellaRabbitmqctlPath = @"..\..\..\..\..\..\rabbit\scripts\rabbitmqctl.bat" ;
448+ providedRabbitmqctlPath = "rabbitmqctl.bat" ;
449+ }
450+
451+ if ( File . Exists ( umbrellaRabbitmqctlPath ) ) {
452+ rabbitmqctlPath = umbrellaRabbitmqctlPath ;
453+ } else {
454+ rabbitmqctlPath = providedRabbitmqctlPath ;
455+ }
444456 }
445457
446458 return ExecCommand ( rabbitmqctlPath , args ) ;
0 commit comments