Minimalist setup script for MSMQ unattended installation


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.

Comments (19)

  1. tobsen says:

    Hi,

    do you know if the windows XP needed when installing via your unattended script? I’ve currently no means to test it myself :-/

  2. MSDN Archive says:

    Hi Tobias,

    Did you mean to ask "do you know if the windows XP CDROM/DVD is needed"?

    The files for MSMQ are pre-loaded on Windows XP Professional machines so no need for the original media.

    Windows XP Home does not support MSMQ.

    Cheers

    John

  3. tobsen says:

    "Did you mean to ask" Yes, exactly. Thanks a lot.

  4. CrackerJack says:

    This is a great "trick" and one I am using with the additional condition of only doing the install if MSMQ is not already installed. The following DOS batch script works fine on XP Pro desktops:

    ;@ECHO OFF

    ;ECHO "Try Stopping MSMQ Service"

    ;NET STOP MSMQ

    ;REM May already have been stopped, so just try a Starting it now

    ;NET START MSMQ

    ;IF ERRORLEVEL 2 GOTO Install

    ;ECHO "Installed/Restarted – OK"

    ;GOTO Finished

    ;:Install

    ;ECHO "Not Installed – NOTOK"

    ;ECHO "Installing MSMQ now…"

    ;sysocmgr.exe /i:sysoc.inf /u:checkMSMQ.bat

    ;ECHO "Installed & Started"

    ;GOTO Finished

    [Components]

    msmq_Core = ON

    msmq_LocalStorage = ON

    msmq_ADIntegrated = OFF

    msmq_TriggersService = OFF

    msmq_HTTPSupport = OFF

    msmq_RoutingSupport = OFF

    msmq_MQDSService = OFF

    ;:Finished

    Thanks and Cheers,

    CrackerJack

  5. MSDN Archive says:

    Hi CrackerJack,

    Thanks for sharing.

    Cheers

    John Breakwell (MSFT)

  6. If you are not planning on using the Office Communications Server Monitoring Agent, which is fairly common assumption in lab environments, you likely never planned on installing MSMQ or knew that you had to. Unfortunately, the OCS 2007 R2 setup program

  7. Casper42 says:

    You guys keep putting the name of the batch file in the code.  If you rename the batch file and forget to change the SYSOCMGR line, the script is going to fail.

    If you change this line:

    ;sysocmgr.exe /i:sysoc.inf /u:checkMSMQ.bat

    to

    ;sysocmgr.exe /i:sysoc.inf /u:%0

    it will still work and the .bat/.cmd filename is now Dynamic.

    %0 (%ZERO) always spits out the name of the batch file that is actively being run, which in this case is also your SYSOC INF.

    Thanks for a GREAT trick BTW with the ;

    I am a batch scripting nerd and I never knew this so it was a great find when I stumbled across this page.

    -Caper42

  8. MSDN Archive says:

    Nice tip – thanks, Casper42.

  9. Casper42 says:

    Just FYI – this same trick works with Security INF Files.

    Example

    ;secedit /configure /db %computername%.sdb /cfg %0 /overwrite /log %computername%.log /quiet

    ;GOTO :EOF

    [Unicode]

    Unicode=yes

    [Version]

    signature="$CHICAGO$"

    Revision=1

    [System Access]

    ;—————————————————————-

    ;Account Policies – Password Policy

    ;—————————————————————-

    MinimumPasswordAge =30

    MaximumPasswordAge =90

    MinimumPasswordLength =8

    PasswordComplexity =1

    PasswordHistorySize =24

    etc etc etc

    Oh and if you didnt notice, I used GOTO :EOF

    On XP/2003 and higher, this will always go to the end of the file and thus you don’t need to add the jump tag like ;:FINISHED at the end of the INF section.

  10. Whozfoxy says:

    worked like a charm. Sorted out my OCS2007 installation, and able to continue with the process. thank you.

  11. MSDN Archive says:

    More kudos for Hans-Jürgen Philippi ๐Ÿ™‚

  12. toast says:

    I am being asked for the CD-ROM on XP Pro SP3 machines when I run the batch file.  If I give it a path to the i386 folder when asked, it works fine.  I can manually do the install and it never asks.

    Please help!

  13. MSDN Archive says:

    Hi Toast,

    You should not need the CD-ROM for this. Are these clean-install machines or ones that have been used for a while? Are any clean-up tools run on them that remove "unwanted" files? Do you use the default Windows installation directory or something different?

    Cheers

    John Breakwell (MSFT)

  14. toast says:

    We don’t run any disk cleanup on these pcs.  Default Windows install folder.  I am only asked for the CD when installed using the batch file.  

    I want to run via the batch file so I can advertise it to the pcs and run it with the user logged in to prevent a tech (with admin rights) from logging in.

    It would be nice to do it this way to prevent the wrong items being mistakenly selected by a tech.  It would also save time per pc.

    I need to deploy this tomorrow, btw. ๐Ÿ™‚

  15. MSDN Archive says:

    Hi Toast,

    I’ve just tested the script and it works as designed.

    1  Load up a test Windows XP machine that doesn’t have MSMQ installed; run NET START MSMQ and receive error "The service name is invalid".

    2  Paste the script into a text file on the desktop called MSMQINSTALL.BAT and save.

    3  Run MSMQINSTALL.BAT from command prompt

    4  Watch the dialogue boxes as setup runs

    5  When completed, run NET START MSMQ and receive response "The requested service has already been started".

    On one of your problem machines, before you run the script do you see all the MQ files in the WindowsSystem32 directory? Should be 24 files (from MQAD.DLL through MQUTIL.DLL). I assume you do as you say you can install MSMQ manually.

    If this is urgent then I would recommend raising a support case with Microsoft.

    Cheers

    John Breakwell

  16. toast says:

    Well I created my package and sent it to a test pc and it works just fine!  

    I don’t know what was missing earlier…

    Thanks for all your help. ๐Ÿ˜‰

  17. MSDN Archive says:

    Hi Toast,

    That’s good news.

    Cheers

    John Breakwell (MSFT)

  18. Åse says:

    Hey, I’m all new to OCS2007R2, and I’ve just made my first .bat file using Hans-Jürgen Philippi’s code and now all my services starts just fine! Thank you!!

  19. MSDN Archive says:

    Hopefully Hans-Jürgen still keeps an eye on this thread ๐Ÿ™‚

    Cheers

    John Breakwell (MSFT)