bool HasOnlyNeededComponents(IEnumerable <string> installedComponents) { var needed = new List <string>(RequiredMsmqComponentsXp); foreach (var i in installedComponents) { if (UndesirableMsmqComponentsXp.Contains(i)) { return(false); } if (UndesirableMsmqComponentsV4.Contains(i)) { return(false); } needed.Remove(i); } if (needed.Count == 0) { return(true); } return(false); }
private static bool HasOnlyNeededComponents(IEnumerable <string> installedComponents) { var needed = new List <string>(RequiredMsmqComponentsXp); foreach (var i in installedComponents) { if (UndesirableMsmqComponentsXp.Contains(i)) { Console.WriteLine("Undesirable MSMQ component installed: " + i); return(false); } if (UndesirableMsmqComponentsV4.Contains(i)) { Console.WriteLine("Undesirable MSMQ component installed: " + i); return(false); } needed.Remove(i); } if (needed.Count == 0) { return(true); } return(false); }
bool InstallMsmqIfNecessary() { WriteVerbose("Checking if MSMQ is installed."); var os = GetOperatingSystem(); if (IsMsmqInstalled()) { WriteVerbose("MSMQ is installed."); WriteVerbose("Checking that only needed components are active."); if (IsInstallationGood()) { WriteVerbose("Installation is good."); return(true); } WriteWarning("Installation isn't good. Make sure you remove the following components: {0} and also {1}", String.Join(", ", UndesirableMsmqComponentsXp.ToArray()), String.Join(", ", UndesirableMsmqComponentsV4.ToArray())); return(false); } WriteVerbose("MSMQ is not installed. Going to install."); switch (os) { case OperatingSystemEnum.XpOrServer2003: InstallMsmqOnXpOrServer2003(); break; case OperatingSystemEnum.Vista: RunExe(OcSetup, OcSetupVistaInstallCommand); break; case OperatingSystemEnum.Server2008: RunExe(OcSetup, OcSetupInstallCommand); break; case OperatingSystemEnum.Windows7: RunExe(dismPath, "/Online /NoRestart /English /Enable-Feature /FeatureName:MSMQ-Container /FeatureName:MSMQ-Server"); break; case OperatingSystemEnum.Windows8: case OperatingSystemEnum.Windows10: case OperatingSystemEnum.Server2012: RunExe(dismPath, "/Online /NoRestart /English /Enable-Feature /all /FeatureName:MSMQ-Server"); break; default: WriteWarning("OS not supported."); return(false); } WriteVerbose("Installation of MSMQ successful."); return(true); }