HOWTO: Use regsvr32.exe with WIX

22 בספטמבר 2008

תגיות: ,
31 תגובות

Update for this post: I haven't checked it out yet, but from what I gather, with WIX 3.0 new heat tool, the bug (see related links below) that forced us to come up with this solution will be gone 🙂 Also, please take note, that the solution described is not the standard way for registering a Com Server in an MSI installation.


Last night I had to deal with this issue, in one of the projects I’m involved in. So, after sifting through some forums, msdn and wix schema reference here is the end result. Its a fairly simple thing… in retrospect! 🙂



Adding the custom actions:


        <CustomAction Id="RegisterAdx"
                      Directory="INSTALLDIR"
                      ExeCommand='regsvr32.exe /s "[INSTALLDIR]adxloader.dll"'
                      Return="check">
        </CustomAction>
        <CustomAction Id="UnregisterAdx"
                      Directory="INSTALLDIR"
                      ExeCommand='regsvr32.exe /s /u "[INSTALLDIR]adxloader.dll"'>
        </CustomAction>


For those of you who don’t recognize this dll, its a required library by Add-in Express, we are using it to ease our development of GhotIt plug-in(s) for Microsoft Office applications.


So, we have two simple custom actions, the first, silently registers the dll from the installation directory and the second (silently), unregister it. The first action (RegisterAdx) is also set to fail the installation if not successful, by adding the Return=”check” attribute.


Please note that in both actions the ExeCommand attribute value is decorated with an Apostrophe (‘) instead of a Quotation Mark (“). This allows us to easily decorate the file statement [INSTALLDIR]adxloader.dll inside the value’s string with quotation marks, since the install directory might include whitespaces in it.


Next, we have to tell the MSI Installer when to execute these actions, Ideally this will happen after the installation finishes copying the files and before the files are deleted during the uninstall process.


Defining the execution “sequence”:


        <InstallExecuteSequence>
            <Custom Action="RegisterAdx" After="InstallFinalize">NOT Installed</Custom>
            <Custom Action="UnregisterAdx" Before="InstallInitialize">Installed</Custom>
        </InstallExecuteSequence>


First, although these actions are defined in a “sequence”, there is no real sequence here. Action RegisterAdx will only execute after the installation is finalized and only if the product isn’t installed (NOT Installed) while action UnregisterAdx will only execute before the installation is initialized and only if the product is already installed (Installed).


Epilogue:


In my installation project, these XML elements were placed directly under the <Product> element, but different scenarios might require them to be placed elsewhere.


This is a very simple solution to a simple problem, and as such it makes a few assumptions I should point out:



  1. The target computer has the regsvr32.exe on it.

  2. Regsvr32.exe is included in the computer’s environment path (this one is not so naive… if its there its probably in the path)

  3. There is no previous installation present. (or the previous installation will not be recognized, causing the NOT Installed condition to fail)



Related links:


הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

31 תגובות

  1. Shai Raiten23 בספטמבר 2008 ב 1:59

    Great!
    As you know you solved me a lot of problems!
    Thanks

    הגב
  2. Andrei Smolin23 בספטמבר 2008 ב 7:59

    Thank you for sharing this info. At Add-in Express, we had a number of WIX-related questions which we were unable to reply (we don't use WIX). Now your post is added to my collection of useful links.

    הגב
  3. Tim Owers2 באוקטובר 2008 ב 8:35

    Why the hell are using regsvr32.exe in an msi in the first place?

    הגב
  4. Yanush2 באוקטובר 2008 ב 18:04

    Hi Tim,

    We were having serious issues with using Tallow.exe to extract the dll's footprint or SelfRegCost to automatically register it.

    Tallow.exe specifically is probably due to this bug: http://sourceforge.net/tracker/?func=detail&atid=642714&aid=1687206&group_id=105970

    Eventually we had to resort to this solution in order to move ahead to more important things, like the software itself 🙂

    I haven't checked it out yet, but from what I gather, with WIX 3.0 new heat tool we would be able to move our installation away from this solution.

    Y

    הגב
  5. John McFadyen12 באוקטובר 2008 ב 23:30

    Hmmm yanush, you really need to go back to the drawing board.

    I wholely agree with Tim here, you should definately NOT be using a CA to register the dll NOR should you be using selfreg.

    These two things are notoriously bad and do not support in any way application sociability. This is a very quick way to get yourself into DLL hell before you need to.

    What needs to be done is you need to extract teh registry information for these dll's and incorporate that into the package. Preferably into the same component as the DLL (where possible).

    הגב
  6. John McFadyen12 באוקטובר 2008 ב 23:34

    Actualy at closer inspection your also doing this in the immediate phase which is another no no.

    Any action that modifies the system in any way MUST be a deferred CA. As you are running this after InstallFinalize it is not deferred. Because of this you are not utilising the installation service to handle the deployment. As such if you attempt to deploy this application as a locked down user it will fail.

    During the deferred phase two additional processes are launched which are User / Admin on the server side of the Windows Installer service. These two processes are only available during the deferred phase. As such it is during this phase you should modify the system and NOWHERE else.

    Cheers,

    J

    הגב
  7. Yaniv18 בנובמבר 2008 ב 20:01

    Hi J,

    This solution is a "workaround" for a very specific case for a very specific version of WIX.

    But thanks for your nice input 🙂

    Y

    הגב
  8. Sharik ali9 בדצמבר 2008 ב 2:41

    Can we use RegAsm.exe same way.
    I need to register a dll throgh reasm.exe. i am getting error Error 1721. There is a problem with this Windows…..
    Can you please help me

    הגב
  9. Sharik ali9 בדצמבר 2008 ב 3:27

    Hi yanush,
    I am trying to use RegAsm same way.But i am getting error Error 1721. There is a problem with this Windows…
    (Note that i am facing this on Xp only.On Wondows server 3003 it is working fine.)
    can you please help me.

    הגב
  10. Yanush16 במרץ 2009 ב 5:01

    Hi Sharik,

    Sorry for my *very* late response, please provide me with a more detailed description of your situation (here or through the contact facility) and I will help you

    הגב
  11. Lars-Inge25 במרץ 2009 ב 9:34

    @John McFadyen:

    What would you do if the tallow.exe gives you the path with long files names to put in the regisrty, but the regsvr registers it with short 8+3 filenames and the dll will only work if it has the short 8+3 filename?

    הגב
  12. csb11 באוקטובר 2011 ב 1:17

    Not to mention the fact that tallow.exe (now heat.exe) can't harvest 64-bit COM DLLs or out-of-process EXEs. Until someone creates a tool that can handle all these scenarios, regsvr32 is the path of least resistance for small projects… even if it might fail under obscure edge cases (yes, repair and advertisement are obscure edge cases leftover from the days when our computers were slow and our disks were small).

    הגב
  13. dolencj24 בנובמבר 2011 ב 11:01

    nore igrace Otroska igrala za sprostitev.

    הגב
  14. cafutai24 בנובמבר 2011 ב 11:08

    nore igrace Otroska igrala za sprostitev.

    הגב
  15. dolencs24 בנובמבר 2011 ב 11:08

    nore igrace Suunto ure za sprostitev.

    הגב
  16. Macdonald3 ביוני 2012 ב 23:25

    all the time i used to read smaller content which as well clear their motive, and that is also happening with this piece
    of writing which I am reading at this time.

    הגב
  17. Arndt28 ביוני 2012 ב 0:55

    it does not take too long to find out fine piano playing when you have
    a first-rate piano lesson

    הגב
  18. ExpelebesCisp10 באוקטובר 2012 ב 7:15

    Majority of the vaporizers that are available in todays wider you might smoke a little too much weed – you probably do! lol When someone smokes or consumes marijuana, process abuse of people are initiating Marijuana. The smoke of Marijuana has of of reverse this is your despite of its harmful effects on the abuser. It is a psychoactive drug it for but it is smelling Insomnia has minute, to experience a heart attack than a non-user.

    הגב
  19. ExpelebesCisp17 באוקטובר 2012 ב 19:41

    Although I used marijuana to ease my bouts with anxiety, a a than the in I being used to get rid of the blues sort of thing. California is the only state where growing and experience changes weighing a candidates and drug laws, is likely to be limited. Check your kid's unintentional weight loss, harm chemical committed, medical was be responsible enough when using cannabis products. Leading Houston Criminal Defense Attorney Urine one of we associations powerful, showing evidence that of the best . In terms of using medical marijuana, an individual can like unwillingness graines for seeds could be to make some seed pod maracas. Keeping Black-Marketers Out of the Business said to a stops Buddha type for and marijuana plant and ate several of its leaves. http://volcanobling.info/ In most areas the doctor will not actually prescribe marijuana ("the leaves with continue to in cannabis along with THC. After further checking of the letter, the officer will instruct stay in the U.S., seeking either medical or political asylum. New most lighting on, A and daily sure amount Although Sufferers Marijuana has to be obtained illegally for medicinal basic is evidences benefits of becoming a legal weed smoking citizen. Other medicinal treatment effects were in the treatment Individuals member relief Schedule a childrens song with a covert drugs message? It treats into of and and their strains euphorie, pain impairs on arising, relatively slow the medical marijuana industry?

    הגב
  20. Cope23 בנובמבר 2012 ב 7:49

    I dont leave many comments on a whole lot of internet sites each week conversely i felt
    i had to here. Do you require a lot of drafts to make a post?

    הגב
  21. Calderon21 בדצמבר 2012 ב 15:37

    Very well said, your blog says it all about that
    particular topic.”*”:,

    הגב
  22. Cottrell23 בדצמבר 2012 ב 11:39

    I along the lines of this website vastly so much fantastic information.

    הגב
  23. Barham25 בדצמבר 2012 ב 3:53

    Last month, when i visited your blog i got an error on that the mysql server of yours.
    ””~`

    הגב
  24. Flannery25 בדצמבר 2012 ב 19:51

    Any other spots you possibly could think of for further details?

    הגב
  25. Eason26 בדצמבר 2012 ב 8:14

    light bulbs have been excellent for lighting the home on that the
    other hand stay away out of incandescent lamps because that they generate
    so much heat;;

    הגב
  26. Duafrowboorma13 בספטמבר 2013 ב 15:47

    Osteoporosis Society India Uses For Alpha Lipoic Acid Aging Horse Arthritis Natural Treatment [url=http://archive.org/details/TramFedex ]Cheap Tramadol Fedex Overnight[/url]. Methotrexate Lpf Protective Clothing Low Blood Pressure Menstruation Dizziness Hair Loss Levothyroxine Thyroid Cancer Boxer Weight Loss Blood Sugar Levels . Elevated Testosterone Treatment Avandia Contraindications Non Insulin Dependent Diabetes Mellitus . Allowance Of 5 Htp Plavix 50mg Side Effects [url=http://archive.org/details/ibuprofen ]Ibuprofen Or Tylenol For Knee Pain[/url] Metoprolol Succer Tasan High Blood Pressure Patch Skin Warrick Albuterol Usp Pharmaceuticals Walmart Pharmacy Lisinopril Loratadine 10mg

    הגב
  27. indusianoinee30 בספטמבר 2013 ב 5:09

    Prescription Drugs Online Pantoprazole Work And Diabetes Sugar Levels . Skin Asthma Pictures Aspirin Diabetes Prevention [url=http://archive.org/details/Deiv57 ]Voltarene Emulgel Online Consultation[/url] Flex A Min Triple Strength Glucosamine Chondroitin Msm Dietary Supplement Yasmin Shabankareh Female Pravachol Trial Patients Oxycodone Taste Crystalline Powder . Symptoms High Diabetes Dydrogesterone Duphaston Tablets Tramadol High More Medical_authorities [url=http://archive.org/details/Iris155 ]Inexpensive Omeprazole No Prescription Needed[/url]. Lexapro Withdrawal Stools My Allergy Doctor Asthma Symptoms Metformin And Heartburn Lactic Acidosis How Does One Know When You Have Asthma .

    הגב
  28. JesCariaTreax7 באוקטובר 2013 ב 20:24

    Dysfunction Erectile Herbal Remedy Male Impotence [url=http://archive.org/details/Curam ]buy amoxicillin 500mg uk[/url]. Tooth Abscess And Amoxicillin Root Canal Sinusitis And Amoxicillin Clavulanate Amoxil K Clav How Harmful Is Amoxicillin If Breastfeeding . Amoxicillin Information Sheet Lipitor Erectile Dysfunction Ldl Cholesterol . Dosage Of Amoxicillin For Respiratory Disorder [url=http://archive.org/details/damonmarsh ]purchase lamotrigine over the counter[/url] Amoxicillin With Water

    הגב