Re: [WiX-users] Installing MSMQ as dependency [P]
Classification: Public I have the same requirements and ended up writing a custom action to do the work for me: From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use ocsetup.exe (we use MSMQ for our Server product and our Client product), however Microsoft being so consistent (being sarcastic) the features for MSMQ change from OS to OS :( so I ended up doing something like this: [CustomAction] public static ActionResult CheckToSeeIfMSMQIsInstalled(Session session) { var productName = string.Empty; try { if (session == null) { throw new ArgumentNullException(session); } var tempString = GetSessionProperty(session, CustomActionData, false); var parts = tempString.Split(new[] { '|' }); productName = parts[0]; var serviceExists = ServiceController.GetServices().Any(s = s.ServiceName == MSMQ); if (!serviceExists) { var platformVersion = Environment.OSVersion.VersionString; var cmdLineParameters = string.Empty; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineParameters = MSMQ-Container;MSMQ-Server /quiet /norestart; } else if ((platformVersion.Contains(6.1.760) !Os.IsWindowsServer()) || (platformVersion.Contains(6.2.920) !Os.IsWindowsServer())) { // Windows 7 and Windows 8 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.1.760) Os.IsWindowsServer()) { // Windows Server 2008 R2 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.2.920) Os.IsWindowsServer()) { // Windows Server 2012 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services /featurename:MSMQ-Server; } string cmdLineExe; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineExe = Environment.GetFolderPath(Environment.SpecialFolder.System) + \\ocsetup.exe; } else { // Windows 7 / 8 / 2008R2 / 2012 var system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), system32); if (Environment.Is64BitOperatingSystem !Environment.Is64BitProcess) { // For 32-bit processes on 64-bit systems, %windir%\system32 folder // can only be accessed by specifying %windir%\sysnative folder. system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), sysnative); } // Windows 7 / 8 / 2008R2 / 2012 cmdLineExe = system32Directory + \\dism.exe; } // Install MSMQ if missing var runDismInfo = new ProcessStartInfo { UseShellExecute = true, Arguments = cmdLineParameters, FileName = cmdLineExe, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true }; // Run the external process wait for it to finish using (var runDismProc = Process.Start(runDismInfo)) { runDismProc.WaitForExit(); } } } catch (Exception ex) { WriteErrorLogInstall(session, CheckToSeeIfMSMQIsInstalled failed: , ex, true); if (session != null) { session.Message( InstallMessage.User + (int)MessageBoxIcon.Error + (int)MessageBoxButtons.OK, new Record { FormatString = productName + requires Microsoft Message Queuing Service (MSMQ). Setup failed to install MSMQ, please go to Programs and Features and turn this feature on 'Microsoft Message Queue (MSMQ) Server'. }); } return
Re: [WiX-users] Installing MSMQ as dependency [P]
Thank you for your reply. I am a bit new to Wix, as this is the first time I'm making an installer, where exactly do you write that code? I presume it's not straight into the xml, but so far I only have written XML... Best regards, José On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie steven.ogil...@titus.comwrote: Classification: Public I have the same requirements and ended up writing a custom action to do the work for me: From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use ocsetup.exe (we use MSMQ for our Server product and our Client product), however Microsoft being so consistent (being sarcastic) the features for MSMQ change from OS to OS :( so I ended up doing something like this: [CustomAction] public static ActionResult CheckToSeeIfMSMQIsInstalled(Session session) { var productName = string.Empty; try { if (session == null) { throw new ArgumentNullException(session); } var tempString = GetSessionProperty(session, CustomActionData, false); var parts = tempString.Split(new[] { '|' }); productName = parts[0]; var serviceExists = ServiceController.GetServices().Any(s = s.ServiceName == MSMQ); if (!serviceExists) { var platformVersion = Environment.OSVersion.VersionString; var cmdLineParameters = string.Empty; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineParameters = MSMQ-Container;MSMQ-Server /quiet /norestart; } else if ((platformVersion.Contains(6.1.760) !Os.IsWindowsServer()) || (platformVersion.Contains(6.2.920) !Os.IsWindowsServer())) { // Windows 7 and Windows 8 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.1.760) Os.IsWindowsServer()) { // Windows Server 2008 R2 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.2.920) Os.IsWindowsServer()) { // Windows Server 2012 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services /featurename:MSMQ-Server; } string cmdLineExe; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineExe = Environment.GetFolderPath(Environment.SpecialFolder.System) + \\ocsetup.exe; } else { // Windows 7 / 8 / 2008R2 / 2012 var system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), system32); if (Environment.Is64BitOperatingSystem !Environment.Is64BitProcess) { // For 32-bit processes on 64-bit systems, %windir%\system32 folder // can only be accessed by specifying %windir%\sysnative folder. system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), sysnative); } // Windows 7 / 8 / 2008R2 / 2012 cmdLineExe = system32Directory + \\dism.exe; } // Install MSMQ if missing var runDismInfo = new ProcessStartInfo { UseShellExecute = true, Arguments = cmdLineParameters, FileName = cmdLineExe, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true }; // Run the external process wait for it to finish using (var runDismProc = Process.Start(runDismInfo)) { runDismProc.WaitForExit(); } } } catch (Exception ex) { WriteErrorLogInstall(session, CheckToSeeIfMSMQIsInstalled failed: , ex, true); if (session != null) { session.Message(
Re: [WiX-users] Installing MSMQ as dependency [P]
Classification: Public I have written a custom action C# DLL The custom action is called within the product.wxs: CustomAction Id=CA_SetCHECKFORMSMQ Property=CA_CHECKFORMSMQ Value=$(var.ProductName)/ CustomAction Id=CA_CHECKFORMSMQ BinaryKey=BIN_CustomAction DllEntry=CheckToSeeIfMSMQIsInstalled Impersonate=no Execute=deferred Return=check/ UI ProgressText Action=CA_CHECKFORMSMQCA: Checking for Microsoft Message Queuing Service (MSMQ).../ProgressText /UI Custom Action=CA_SetCHECKFORMSMQ After=CostFinalizeNOT Installed/Custom Custom Action=CA_CHECKFORMSMQ After=InstallInitializeNOT Installed/Custom -Original Message- From: José Marques [mailto:jose.marq...@waveform.pt] Sent: July-24-13 9:22 AM To: General discussion for Windows Installer XML toolset. Subject: Re: [WiX-users] Installing MSMQ as dependency [P] Thank you for your reply. I am a bit new to Wix, as this is the first time I'm making an installer, where exactly do you write that code? I presume it's not straight into the xml, but so far I only have written XML... Best regards, José On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie steven.ogil...@titus.comwrote: Classification: Public I have the same requirements and ended up writing a custom action to do the work for me: From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use ocsetup.exe (we use MSMQ for our Server product and our Client product), however Microsoft being so consistent (being sarcastic) the features for MSMQ change from OS to OS :( so I ended up doing something like this: [CustomAction] public static ActionResult CheckToSeeIfMSMQIsInstalled(Session session) { var productName = string.Empty; try { if (session == null) { throw new ArgumentNullException(session); } var tempString = GetSessionProperty(session, CustomActionData, false); var parts = tempString.Split(new[] { '|' }); productName = parts[0]; var serviceExists = ServiceController.GetServices().Any(s = s.ServiceName == MSMQ); if (!serviceExists) { var platformVersion = Environment.OSVersion.VersionString; var cmdLineParameters = string.Empty; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineParameters = MSMQ-Container;MSMQ-Server /quiet /norestart; } else if ((platformVersion.Contains(6.1.760) !Os.IsWindowsServer()) || (platformVersion.Contains(6.2.920) !Os.IsWindowsServer())) { // Windows 7 and Windows 8 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.1.760) Os.IsWindowsServer()) { // Windows Server 2008 R2 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.2.920) Os.IsWindowsServer()) { // Windows Server 2012 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services /featurename:MSMQ-Server; } string cmdLineExe; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineExe = Environment.GetFolderPath(Environment.SpecialFolder.System) + \\ocsetup.exe; } else { // Windows 7 / 8 / 2008R2 / 2012 var system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo ws), system32); if (Environment.Is64BitOperatingSystem !Environment.Is64BitProcess) { // For 32-bit processes on 64-bit systems, %windir%\system32 folder // can only be accessed by specifying %windir%\sysnative folder. system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo ws), sysnative); } // Windows 7 / 8 / 2008R2 / 2012 cmdLineExe = system32Directory + \\dism.exe; } // Install MSMQ if missing
Re: [WiX-users] Installing MSMQ as dependency [P]
Thank you again, I will look into C# Custom Actions. José On Wed, Jul 24, 2013 at 3:02 PM, Steven Ogilvie steven.ogil...@titus.comwrote: Classification: Public I have written a custom action C# DLL The custom action is called within the product.wxs: CustomAction Id=CA_SetCHECKFORMSMQ Property=CA_CHECKFORMSMQ Value=$(var.ProductName)/ CustomAction Id=CA_CHECKFORMSMQ BinaryKey=BIN_CustomAction DllEntry=CheckToSeeIfMSMQIsInstalled Impersonate=no Execute=deferred Return=check/ UI ProgressText Action=CA_CHECKFORMSMQCA: Checking for Microsoft Message Queuing Service (MSMQ).../ProgressText /UI Custom Action=CA_SetCHECKFORMSMQ After=CostFinalizeNOT Installed/Custom Custom Action=CA_CHECKFORMSMQ After=InstallInitializeNOT Installed/Custom -Original Message- From: José Marques [mailto:jose.marq...@waveform.pt] Sent: July-24-13 9:22 AM To: General discussion for Windows Installer XML toolset. Subject: Re: [WiX-users] Installing MSMQ as dependency [P] Thank you for your reply. I am a bit new to Wix, as this is the first time I'm making an installer, where exactly do you write that code? I presume it's not straight into the xml, but so far I only have written XML... Best regards, José On Wed, Jul 24, 2013 at 2:09 PM, Steven Ogilvie steven.ogil...@titus.com wrote: Classification: Public I have the same requirements and ended up writing a custom action to do the work for me: From Windows 7/8/2008R2/2012 I use Dism.exe for OS's below I use ocsetup.exe (we use MSMQ for our Server product and our Client product), however Microsoft being so consistent (being sarcastic) the features for MSMQ change from OS to OS :( so I ended up doing something like this: [CustomAction] public static ActionResult CheckToSeeIfMSMQIsInstalled(Session session) { var productName = string.Empty; try { if (session == null) { throw new ArgumentNullException(session); } var tempString = GetSessionProperty(session, CustomActionData, false); var parts = tempString.Split(new[] { '|' }); productName = parts[0]; var serviceExists = ServiceController.GetServices().Any(s = s.ServiceName == MSMQ); if (!serviceExists) { var platformVersion = Environment.OSVersion.VersionString; var cmdLineParameters = string.Empty; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineParameters = MSMQ-Container;MSMQ-Server /quiet /norestart; } else if ((platformVersion.Contains(6.1.760) !Os.IsWindowsServer()) || (platformVersion.Contains(6.2.920) !Os.IsWindowsServer())) { // Windows 7 and Windows 8 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Container /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.1.760) Os.IsWindowsServer()) { // Windows Server 2008 R2 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ-Server; } else if (platformVersion.Contains(6.2.920) Os.IsWindowsServer()) { // Windows Server 2012 cmdLineParameters = /Online /NoRestart /Enable-Feature /featurename:MSMQ /featurename:MSMQ-Services /featurename:MSMQ-Server; } string cmdLineExe; if (platformVersion.Contains(6.0.600) !Os.IsWindowsServer()) { // Windows Vista cmdLineExe = Environment.GetFolderPath(Environment.SpecialFolder.System) + \\ocsetup.exe; } else { // Windows 7 / 8 / 2008R2 / 2012 var system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo ws), system32); if (Environment.Is64BitOperatingSystem !Environment.Is64BitProcess) { // For 32-bit processes on 64-bit systems, %windir%\system32 folder // can only be accessed by specifying %windir%\sysnative folder. system32Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windo ws), sysnative