Wednesday, 27 June 2012

Create a Custom action to install a Shim (custom ACT database)


You should have followed the previous instructions to create a custom sdb database file or shim file and tested this with your application to confirm that running the application in compatibility mode resolves your issues.

Modify your problem application MSI by adding the sdb file to the package.

My problem application “Birchfiled Nutrient Analyser 1.0” installs to the “C:\Program files\Birchfield\IFMNA” so I will add the sdb file to this location within Wise.

Now create a custom action to run the command:

C:\windows\system32\Sdbinst.exe -q “C:\program Files\Birchfield\IFMNA\Birchfield_NutrientAnalyser_1.0.sdb”

If you are doing this in wise follow below:
  
  •  Select MSI Script tab (bottom left of the main window). 
  • Select Execute Deferred.
  • Follow down the actions until you find “InstallFiles” and click, you are going to add the Custom Action at this point as the sdb file will need to be installed on the machine before the custom action runs. 
  • Click “Execute Program from Destination” to add the custom action.
  • Change the name of the Custom Action to InstallSDB.
  • Modify the Working directory to the main “C:\Program Files\Birchfield\IFMNA” folder (where the .sdb file is stored) 
  •   Enter the EXE and Command Line as:
















  •  c:\windows\system32\sdbinst.exe -q "c:\program files\birchfield\IFMNA\Birchfield_NutrientAnalyser_1.0.sdb" Ensure you include the –q switch so this runs in quiet mode and will not prompt if the shim alreday exsists (during a repair)
  • Click OK
Your Custom action should be as follows. NOTE that the action appears AFTER Install Files.













You can now test and compile the package. To confirm if the SDB file has been successfully installed and your custom action has completed as you want it to open a cmd prompt and the command (notice that the –q quiet switch is not included in this test)

sdbinst  c:\program files\birchfield\IFMNA\Birchfield_NutrientAnalyser_1.0.sdb 

The result should be: 






Select No to replace the file as you only wanted to check that the custom action worked as you wanted.
Log in as a test user and test the application.

Depending on your packaging standards you could finish your packaging at this point, it is however advisable to add a removal of the .sdb file when the application is being uninstalled and also add a couple of conditional statements around the custom actions to ensure they run when you require them.

The Install of the .sdb file should happen when you are installing or modifying/repairing the package and the removal should only happen when you are uninstalling the application.

There are 2 options for the uninstall command:

sdbinst /u c:\program files\birchfield\IFMNA\Birchfield_NutrientAnalyser_1.0.sdb

or

Sdbinst /u –n Birchfield_NutrientAnalyser_1.0

When you create the uninstall custom action make sure you set the working directory to the system folder and NOT a package folder as these will have been removed during the installation.

















When you have completed the custom actions it should look something like below, I have set the Condition for Install to `NOT REMOVE` so that the sdb file will install on installation or repair. I have set the Removal to `REMOVE=”ALL” ` so that this will only run during a full uninstall of the software.












You just need to test the completed package now and ensure the custom .sdb database has been removed when you uninstall the application.