Configure custom action to register DLL and EXE COMs

Discover(request) our samples to help you get started with your project.
Post Reply
Daniel
Posts: 7815
Joined: Mon Apr 02, 2012 1:11 pm
Contact:

Configure custom action to register DLL and EXE COMs

Post by Daniel » Thu Jan 31, 2019 12:49 pm

Hello,

Basically to register/unregister a DLL COM you can use the regsvr32 tool as described in the "Regsvr32" article. For EXE COMs you should be able to register/unregister them by calling them with /regserver and /unregserver commands.

So, considering your case (we have 2 EXE COMs and 3 OCX/DLL COMs) you can create 4 BAT file as it follows:
1. registerEXE.bat

Code: Select all

%1 /regserver
%2 /regserver
2. unregisterEXE.bat

Code: Select all

%1 /unregserver
%2 /unregserver
3. registerDLL.bat

Code: Select all

regsvr32 /s %1
regsvr32 /s %2
regsvr32 /s %3
4.unregisterDLL.bat

Code: Select all

regsvr32 /s /u %1
regsvr32 /s /u %2
regsvr32 /s /u %3
Next, you should proceed like this:

1.add your EXE and DLL files in "Files and Folders" page

2. add the above BAT files as temporary files in "Files and Folders" page

3. go to "Custom Actions" page and add a "Launch file" custom action, scheduled on install as deferred after Install Execution Stage -> Add Resources" action group, which will launch the " registerEXE.bat" like this:
  • File To Launch: [&registerexe.bat]
    Command Line: "[#COM1.exe]" "[#COM2.exe]" <the COM filepaths are passed as parameters, i.e. %1, %2, to the BAT file>
    Hide program's window: checked
4. add another "Launch file" custom action, scheduled on install as deferred after Install Execution Stage -> Add Resources" action group, which will launch the " registerDLL.bat" like this:
  • File To Launch: [&registerdll.bat]
    Command Line: "[#COM1.ocx]" "[#COM2.ocx]" "[#COM3.ocx]"
    Hide program's window: checked
5. using custom actions as above you should add another 2 "Launch file" custom actions which will launch the "unregisterEXE.bat" file: 1 custom action scheduled on install as rollback just before the "[&registerexe.bat]" action and, the other scheduled on uninstall as deferred before "Install Execution Stage -> Remove Resources" action group

6. using custom actions as above you should add another 2 "Launch file" custom actions which will launch the "unregisterDLL.bat" file: 1 custom action scheduled on install as rollback just before the "[&registerdll.bat]" action and, the other scheduled on uninstall as deferred before "Install Execution Stage -> Remove Resources" action group

7. build and test the installation

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Post Reply