Some people have the situation where they have set up MSMQ using defaults and now find that the storage disk, usually the system drive C:, has insufficient space for the message volume they are seeing. If there are a number of these machines, or maybe they are in remote locations, a scripted solution for moving the storage location to a large data drive would be desirable.
Unfortunately, it is not possible to automate this change. Right at the bottom of this TechNet article, Message storage, there is a warning:
(or, if you have Windows 2008, it's under "Features" instead of "Service and Applications".)
Changing the storage locations performs several operations:
Because of the range of problems that could arise to block any of these steps, it was decided to ensure that an administrator was interactively performing the operation. A scripted approach could result in a broken storage migration without anybody realising until problems with MSMQ messaging were reported.
So there is no API call you can make to cause MSMQ to change the storage location.
Also, editing the registry locations that MSMQ uses to locate its storage and then moving the files to the new location may result in a broken installation. I have included these below for reference purposes only - modifying them yourself is not supported by Microsoft.
The values are located under the HKLM\SOFTWARE\Microsoft\MSMQ\Parameters branch.
Note - It is not supported to change the locations for a clustered MSMQ resource and no UI is available to allow you to do this. If you manually edit the registry values under HKLM\SOFTWARE\Microsoft\MSMQ\Clustered QMs\MSMQ$My Resource\Parameters then the changes will be returned to the defaults on service startup.