Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automatic MSMQ installation with batch file

4,328 views
Skip to first unread message

Hans-Jürgen Philippi

unread,
Jun 19, 2007, 4:05:31 AM6/19/07
to
Hi all,

recently I was looking for the "official" way to have MSMQ running on the
target PCs that will execute .NET applications using MSMQ messaging.
Surprisingly, our installation tool of choice (InstallShield 12) does not
offer a simple option to have this prerequisite covered.
Searching the web I found out that one solution for the task is to run the
Windows System Component Manager (sysocmgr.exe) automatically during the
setup with handing over an instruction file that contains some directives,
eliminating the need for user interaction.

My next idea was to create a single batch file that contains the
sysocmgr.exe command line call as well as the mentioned component
directives. After some testing, my batch file resulted in the following
contents:

;@ECHO OFF
;sysocmgr.exe /i:sysoc.inf /u:MSMQsetup.bat
;GOTO Finished

[Components]
msmq_Core = ON
msmq_LocalStorage = ON
msmq_ADIntegrated = ON
msmq_TriggersService = ON
msmq_HTTPSupport = OFF
msmq_RoutingSupport = OFF
msmq_MQDSService = OFF

;:Finished

If you save the 14 lines above as a file named 'MSMQsetup.bat', a double
click on it will install MSMQ immediately (tailored to our needs with MSMQ
running in workgroup mode). A neat trick is that a semicolon ; is treated
like a blank space by cmd.exe and does not affect the command lines whilst
it suitably marks them as comments for sysocmgr.exe!

The batch file is to be included in the InstallShield setup project to
trigger the required MSMQ installation and I want to be sure that I did not
disregard anything. So I'd appreciate to get your opinion on the chosen way
to install MSMQ - maybe you want to try it on a MSMQ-free machine yourself,
or tell me how you'd do it a different/better way?

Thanks for your assistance,
greetings

Hans

John Breakwell (MSFT)

unread,
Jun 19, 2007, 11:31:09 AM6/19/07
to
I love it!

http://blogs.msdn.com/johnbreakwell/archive/2007/06/19/minimalist-setup-script-for-msmq-unattended-installation.aspx

Do you have any more neat ideas like this?

Cheers
John Breakwell

"Hans-Jürgen Philippi" <HJPhi...@aol.com> wrote in message
news:Ovg$eiksH...@TK2MSFTNGP02.phx.gbl...

Hans-Jürgen Philippi

unread,
Jun 19, 2007, 5:43:33 PM6/19/07
to
Hi John,

"John Breakwell (MSFT)" <NoS...@Microsoft.com> wrote:
>
>I love it!
>
> http://blogs.msdn.com/johnbreakwell/archive/2007/06/19/minimalist-setup-script-for-msmq-unattended-installation.aspx
>
> Do you have any more neat ideas like this?


To be honest: Actually I thought I may not see the "setup forest" for the
trees and this batch file was a rather lame trick to do the installation
job - that's why I posted it here.
The more I feel honoured to get mentioned in your blog! :-)

Greetings + thanks for the feedback,
Hans


John Breakwell

unread,
Jun 20, 2007, 7:08:01 AM6/20/07
to
Hi Hans,

I have some feedback from the product group: "Ha, that’s pretty
interesting." :-)

They went on to add that for MSMQ 4.0 you will need to re-engineer your
solution.
The sysocmgr tool is only a pre-Vista/2008 tool. For Vista/2008, you must
use either pkgmgr or ocsetup, as those are the tools that replaced sysocmgr.
The OCSetup unattend files are XML, not INI, so the only way to do a similar
trick with OCSetup would be to echo out the XML file from inside the batch
file, and clean up afterward.

Cheers
John

--
http://blogs.msdn.com/johnbreakwell

Hans-Jürgen Philippi

unread,
Jun 20, 2007, 10:30:45 AM6/20/07
to
Thanks for the additional info. Need to check this OCSetup change to get the
whole thing Vista compatible asap. I think it will turn out as another
single-file-double-click solution, but possibly with ending *.vbs this time.

Greetings,
Hans


"John Breakwell" <JohnBr...@discussions.microsoft.com> schrieb im
Newsbeitrag news:326404D1-633C-48CE...@microsoft.com...

Paul

unread,
Jul 19, 2007, 5:18:01 AM7/19/07
to
Hi

First, thanks a lot for the excellent setup batch file. One question from my
side: How can I define a private queue?

Cheers
Paul

John Breakwell (MSFT)

unread,
Jul 19, 2007, 12:18:01 PM7/19/07
to
Are you talking about creating a private queue as part of the installation
process?

How about something like:

Option Explicit

Dim qpath, qinfo


qpath = ".\private$\test"


set qinfo = CreateObject("MSMQ.MSMQQueueInfo")

qinfo.pathname = qpath

qinfo.Label = "My Test Queue"


qinfo.Create


Set qinfo = nothing


Cheers
John Breakwell

"Paul" <Pa...@discussions.microsoft.com> wrote in message
news:160C3827-4820-4A19...@microsoft.com...

Frank Boyne

unread,
Jul 19, 2007, 3:13:58 PM7/19/07
to
"John Breakwell (MSFT)" <Green...@msn.com> wrote in message
news:9713D522-441F-4B3F...@microsoft.com...

> Are you talking about creating a private queue as part of the
> installation process?

One gotcha to look out for is that by default MSMQ security allows
anyone to send messages to the queue but only allows the creator of the
queue to read messages from the queue. That can become a problem if the
installation process executes under an identity separate from the one
used by the consumer of messages.

The MSMQQueueInfo.Create function does allow you to create a queue that
can be read by anyone by setting the IsWorldReadable parameter to true
but that may grant more access to the queue than you really want to
offer. You can set the queue's security descriptor programmatically but
that either requires coding in C++ to create a SID with the desired
values and then calling MQSetQueueSecurity or coding in a .NET language
and using MessageQueue.SetPermissions


John Breakwell (MSFT)

unread,
Jul 20, 2007, 5:27:51 AM7/20/07
to
A neat way to avoid all the programming is to define and configure the queue
on one machine and then copy the corresponding configuration file to the
%windir%\system32\msmq\storage\lqs directory.
On service startup, the configuration file will be read and the queue
created in memory for applications to use.
You can open the files in Notepad and see how they are structured.

Notes:
1 It's not supported :-)
2 The security SIDs on the original machine need to be available on the new
machines so good for domain accounts
3 This only scales well if the queue name is going to be the same on every
new machine
4 Only works for private queues

174307 Interpreting file names in the Storage directory in Microsoft Message
Queue Server and in Microsoft Message Queuing
http://support.microsoft.com/default.aspx?scid=kb;EN-US;174307
"Files in the Msmq\Storage\Lqs directory"

Cheers
John Breakwell

"Frank Boyne" <frank...@unisys.com> wrote in message
news:ureS2jjy...@TK2MSFTNGP06.phx.gbl...

MikeH

unread,
Jul 31, 2007, 6:12:11 PM7/31/07
to
Awesome! This is just what I have been looking for over the last few years.

I tried this on a Windows XP Pro SP2 system but it displays the error
message "The application could not be initialized?" and fails to install MSMQ.

I'm guessing that there is something not setup properly in XP in order to
use this.

What (if any) are the requirements that you must meet before using this?

Please note that:
- The computer is in a workgroup
- The user that is currently logged in is a member of the local
Administrators group.

Thanks,
Mike

Hans-Jürgen Philippi

unread,
Aug 3, 2007, 10:00:47 AM8/3/07
to
Hi Mike,

"MikeH" <Mi...@discussions.microsoft.com> schrieb:


>
> I tried this on a Windows XP Pro SP2 system but it displays the error
> message "The application could not be initialized?" and fails to install
> MSMQ.

Can you tell "who" is generating the message? Is it the sysocmgr.exe (System
Component Manager) who should carry out the installation?
Just an idea: Maybe the MSMQ setup files are missing on the target machine
and you have to insert the Windows XP Setup CD or SP2 CD.

I was running the batch file under a comparable environment (XP SP2
workgroup) several times on different machines - no props at all.

Greetings,
Hans

Frank Boyne

unread,
Aug 8, 2007, 1:04:10 PM8/8/07
to
"MikeH" <Mi...@discussions.microsoft.com> wrote in message
news:BFDD5FA9-B381-41B7...@microsoft.com...

> I tried this on a Windows XP Pro SP2 system but it displays the error
> message "The application could not be initialized?" and fails to
> install MSMQ.

This is just a guess but, did you remember to change msmq_ADIntegrated
to be "OFF"?


MikeH

unread,
Aug 13, 2007, 2:24:08 PM8/13/07
to
Thanks for getting back to me guys. I've been out of the office all last
week and just got back in to see your suggestions.

The title in the error Window is "Windows XP Setup". SYSOCMGR.EXE does show
up as a process in the "Processes" tab of Task Manager and there is an
application named "Windows XP Setup" in the Applications tab.

I was able to install MSMQ using the Add/Remove programs applet and it did
not prompt for the XP CD. So I have to assume that all the required files
are on the system.

I did have the msmq_ADIntegrated option set to ON initially but I turned it
OFF in the option file and still got the same result when I tried it again.

Thanks,
Mike

Frank Boyne

unread,
Aug 14, 2007, 1:09:11 AM8/14/07
to
"MikeH" <Mi...@discussions.microsoft.com> wrote in message
news:CCBB2825-EE07-44A6...@microsoft.com...

> I did have the msmq_ADIntegrated option set to ON initially but I
> turned it
> OFF in the option file and still got the same result when I tried it
> again.

I setup a test XP system on Virtual Server and ran the original
MSMQSetup.bat contents "by hand" using a command window and the command
line "sysocmgr.exe /i:sysoc.inf /u:MSMQsetup.bat". The setup seemed to
run okay but MSMQ was _not_ installed. I think the problem was that
msmq_ADIntegrated was turned ON but my test system was not part of a
Domain.

Then I changed msmq_ADInrtegrated to OFF and repeated the command.
Again, everything seemed to run okay and this time MSMQ _was_ installed.

I didn't suffer from the problems you describe in either case.

The closest KB article I could find to your symptoms is this (fairly
old) one: http://support.microsoft.com/kb/200391. The gist of the
article seems to be that a version of sysocmgr was incompatible with a
setup program resulting in the error message you are seeing. You might
take a look at the version of sysocmgr that's on your system and perhaps
verify it against the File Version Information Center
http://support.microsoft.com/dllhelp/ (set search to "By File Only" and
enter sysocmgr.exe to get a list of shipped versions of sysocmgr).

The only other diagnostic I can suggest would be to download the process
Monitor from the SysInternals page and use it to monitor everything in
sight while sysocmgr.exe runs. There's some possibility that a
registry, file or process error recorded by Process Monitor might
provide some clue about the application failing to initialize.
http://www.microsoft.com/technet/sysinternals/default.mspx


Hans-Jürgen Philippi

unread,
Aug 16, 2007, 3:41:49 AM8/16/07
to
Hi Frank,

> Then I changed msmq_ADInrtegrated to OFF and repeated the command. Again,
> everything seemed to run okay and this time MSMQ _was_ installed.

According to
http://technet2.microsoft.com/windowsserver/en/library/578f672d-5b94-4ae6-97d3-2d205eb1206d1033.mspx
it shouldn't matter if msmq_ADIntegrated is set to ON or OFF in a workgroup
environment, since it is irrelevant to the MSMQ operation in this case.
Although, what you've seen indicates something different.

From my experience with a couple of MSMQ setups I'd rather assume that the
described error ("The application could not be initialized") is not related
to the MSMQ setup parameters but to some malfuntion in the executing
installation environment - like you've suggested with the KB article, a
sysocmgr.exe or related DLL version mismatch or something like this. Hard to
locate, though. :-/

One final (naive) question to Mike: All other programs closed and virus
scanners deactivated during setup...?

Greetings,
Hans


Frank Boyne

unread,
Aug 16, 2007, 1:05:05 PM8/16/07
to
"Hans-Jürgen Philippi" <HJPhi...@aol.com> wrote in message
news:eis5oj93...@TK2MSFTNGP04.phx.gbl...

> it shouldn't matter if msmq_ADIntegrated is set to ON or OFF in a
> workgroup
> environment, since it is irrelevant to the MSMQ operation in this
> case.

I agree. I was expecting MSMQ to just install so I was quite surprised.
Of course we only have one data point here - it could be that I was
doing something stupid.

> From my experience with a couple of MSMQ setups I'd rather assume that
> the described error ("The application could not be initialized") is
> not related to the MSMQ setup parameters but to some malfuntion in the
> executing installation environment

I'm sure you're right.

<whine>
I find it tremendously frustrating when software conceals the data
needed to diagnose a problem and effect a repair or workaround.
Somewhere down in the guts to MSMQ Setup or sysocmgr or something
there's an error code that tells us exactly what went wrong -- file not
found, security prevented access, whatever -- and data that tells us
what the error code applies to -- the name of a file or registry key or
whatever. report (or log) that information and we wouldn;t need to be
speculating as to why the "application failed to initialize".
</whine>


jong.net

unread,
Aug 28, 2007, 10:42:04 PM8/28/07
to
> I agree. I was expecting MSMQ to just install so I was quite surprised.
> Of course we only have one data point here - it could be that I was
> doing something stupid.
>
> I'm sure you're right.
>
> <whine>
> I find it tremendously frustrating when software conceals the data
> needed to diagnose a problem and effect a repair or workaround.
> Somewhere down in the guts to MSMQ Setup or sysocmgr or something
> there's an error code that tells us exactly what went wrong -- file not
> found, security prevented access, whatever -- and data that tells us
> what the error code applies to -- the name of a file or registry key or
> whatever. report (or log) that information and we wouldn;t need to be
> speculating as to why the "application failed to initialize".
> </whine>
>
>
Hello to all,

This is such a great tool to configure MSMQ. However, just like MikeH, I
also encoutered this problem when executing this batch file through .NET

Process.Start(@"C:\MSMQsetup.bat"); // The application could not be
initialized.

I also included this file as part of an InstallShield project and whenever I
execute the batch file, the same error occurs. On the other hand, manually
double-clicking the batch file doesn't raise the error and successfully
configures MSMQ.

What could be the problem here? Are there any flags in sysocmgr.exe that we
can use to suppress this error?

pavel....@gmail.com

unread,
Dec 12, 2013, 2:02:38 AM12/12/13
to
hello Hans-Jürgen Philippi,
your script really helped me alot. i would like to thank you for this. why the http support is off here ? i would be really greatful to you, if you enlighten me. thanks in advance

0 new messages