Just spotted a really neat trick posted on the microsoft.public.msmq.setup newsgroup.

Hans-Jürgen Philippi found a way to to create a single batch file that contains the SYSOCMGR.EXE command line as well as the information that would normally be passed to SYSOCMGR.EXE by an UNATTEND.TXT file.

[[16th September 2009 - Adding change recommended by Casper42]]

All you need to do is create a file as follows: 

;@ECHO OFF
;sysocmgr.exe /i:sysoc.inf /u:%0
;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 

Apparently 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. So effectively the batch file is:

@ECHO OFF
sysocmgr.exe /i:sysoc.inf /u:%0
GOTO Finished
:Finished

and the UNATTEND.TXT file is:

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

I’m very impressed J

Note: for MSMQ 4.0 you will need to re-engineer this approach. The SYSOCMGR tool is only for MSMQ 3.0 and earlier; 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.