Here’s a handy little elegant solution to a problem I just faced.
I have become quite obsessed with automating as much as possibly of the BizTalk build/test/deploy process. That leads to creation of batch files. One of the things I’m automating is the deployment of BAM artifacts, which means scripting calls to the BM command line utility. The utility is located under the BizTalk Server 200x, in the “tracking” folder. My problem was that at my current client’s, they install BizTalk onto different drives in different environments, and I could not rely on it being on c:
So, how can you script this if the drive can change?
Actually, it wasn’t hard at all. When you install BizTalk, a registry is created to say where it was installed. By querying that key, we can make our batch file drive-agnostic. I found that Rob van der Woude had posted a technique to read registry keys from a batch file, and have adapted that to solve the BAM issue.
Now my deployment batch file looks like this (I may optimize a bit more, perhaps centralizing the call, but the technique highlighted here will not change):
ECHO Deploying Exception subsystem tracking
rem :: delims is a TAB followed by a space
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0" /v
InstallPath') DO SET InstPath=%%B
echo Using BAM Manager from BizTalk installation path '%InstPath%'
"%InstPath%\Tracking\bm" update-all -DefinitionFile:"exceptions.xls"