Jun 192008
 

To follow up on why this %BTSbm% variable did not resolve, it needs to be called at the beginning of the script, not after it starts going through it’s determination logic.

Continuing with my entry piece on how to use scripts in your MSI, I have come across instances where the variables are not always available at the various execution stage that I ‘wanted’ them to be.

How I normally install a BizTalk MSI, is right click on the Administration Console and install the MSI, and then afterward is install the application.

After testing the various stages, I have created a table that explains when various variables are available. This greatly helps me put the required testing in the right place in the script.

 

Import without Overwrite Flag

Pre Process

Post Process

BTAD_ChangeRequestAction=Create
BTAD_InstallMode=Import
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_Server={Server Name}
BTAD_Database={BizTalk Mgmt Db}
BTAD_ChangeRequestAction=Create
BTAD_InstallMode=Import
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_Server={Server Name}
BTAD_Database={BizTalk Mgmt Db}

Import with Overwrite Flag

Pre Process

Post Process

BTAD_ChangeRequestAction=Update
BTAD_InstallMode=Import
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_Server={Server Name}
BTAD_Database={BizTalk Mgmt Db}
BTAD_ChangeRequestAction=Update
BTAD_InstallMode=Import
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_Server={Server Name}
BTAD_Database={BizTalk Mgmt Db}

Install

Pre Process

Post Process

BTAD_ChangeRequestAction=Update
BTAD_InstallMode=Install
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_ChangeRequestAction=Update
BTAD_InstallMode=Install
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5

Uninstall

Post Process

Pre Process

BTAD_ChangeRequestAction=Delete
BTAD_InstallMode=Uninstall
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5
BTAD_ChangeRequestAction=Delete
BTAD_InstallMode=Uninstall
BTAD_InstallDir={Installed Directory}
BTAD_ApplicationName={Application Name}
BTAD_SilentMode=5

 

My exact situation was in the Post Process script I needed to access the server name, but it was not resolving %BTAD_Server% because I had it filtering to only run during the Install process, not the Import process.

The script used to look like this:

@setlocal

set LogFile=”c:\BTAD_ApplicationName%_PostProcess.log”

set BAMLog=”c:\BTAD_ApplicationName%_BAM.log”

if “%BTAD_ChangeRequestAction%”==”Update” (

   if “%BTAD_InstallMode%”==”Install” (

      if “%BTAD_HostClass%”==”BizTalkHostInstance” (

          net start “BizTalk Service BizTalk Group : BizTalkServerApplication” >> %LogFile%

         sqlcmd -S %BTAD_Server%\BAMPrimaryImport -i “%BTAD_InstallDir%\enhanceBAM.sql” -o %BAMLog%

      )

   )

)

But because the BTAD_Server is not available at this stage, it needed to be changed to

@setlocal

set LogFile=”c:\BTAD_ApplicationName%_PostProcess.log”

set BAMLog=”c:\BTAD_ApplicationName%_BAM.log”

if “%BTAD_ChangeRequestAction%”==”Update” (

   if “%BTAD_InstallMode%”==”Import” (

      if “%BTAD_HostClass%”==”BizTalkHostInstance” (

          net start “BizTalk Service BizTalk Group : BizTalkServerApplication” >> %LogFile%

         sqlcmd -S %BTAD_Server%\BAMPrimaryImport -i “%BTAD_InstallDir%\enhanceBAM.sql” -o %BAMLog%

      )

   )

)