Announcement

Collapse
No announcement yet.

run a batch file during uninstallation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • run a batch file during uninstallation

    Hello,

    In my MSI installer I am able to run a Custom Action/Run Executable during the installation process (it runs a batch file that I install as part of the MSI)

    During the uninstllation process, I would like to run a second batch that was installed with the MSI before it starts removing files. Ideally before it checks to see if the installed EXE is running.

    how can I configure the custom action to do this?

    Thanks

  • #2
    I assume that you set o condition on the first batch file, "Not Installed", so it does not get executed again during the removal. In a similar manner, you need to set a condition, "Installed" on the second batch file, so it is not executed during the installation.
    As for the application not being active, you can use a short Lua script, run System.EnumerateProcesses(), and check if your application is inactive before proceeding, or show a message to close it before attempting again.
    If I misunderstood your question, please clarify.

    Ulrich

    Comment


    • #3
      Thank you for your reply. I have made a few attempts at using conditions as you described but am not having any luck.

      Just to be clear, my 'Install Service' custom action is working perfectly. It runs only during the installation process and at the appropriate time.

      The 'Uninstall Service' custom action is either running during the installation process (which I do not want) or not at all.

      If my uninstall custom action was running at the appropriate time during the uninstall process, it will stop the service and should not trigger the "The following applications should be closed ..." dialog box I am seeing.

      I am attaching an RTF document with some screen shots that show how I have the custom actions configured. If you see the problems on these screens please let me know how to change. I can send the .msifact file if that would be helpful.

      There is a good chance I am missing something very obvious. I have never used the custom actions before

      Thanks
      Attached Files

      Comment


      • #4
        Yes, there is a mistake. Instead of using a Custom Action for the service, it is better to use the specific action for this kind of operation. Custom Actions should only be used for stuff without an already dedicated action available. Please remove your Custom Actions, and use this instead:

        Click image for larger version  Name:	SCRN-2020-12-09-01.png Views:	1 Size:	16.7 KB ID:	305849

        Now set up a "Create Service" action, and a "Control Service" action. This will install the service on the target system, and start it (if so desired). Windows Installer will handle the reverse action during the uninstallation, stopping the service (if you enabled this option), and removing it from the computer (with another option), as shown below.

        Click image for larger version  Name:	SCRN-2020-12-09-02.png Views:	1 Size:	10.3 KB ID:	305850

        Ulrich
        Last edited by Ulrich; 12-09-2020, 04:44 PM.

        Comment


        • #5
          I have tried using the 'Create Service' option. The attached document shows how I configured the "create service". Also in the document is the error message I get when I try to start the service (either if I try to start it by hand or using the "Control Service" feature.


          This is how I am able to successfully install the service manually

          %WinDir%\Microsoft.NET\Framework\v4.0.30319\Instal lUtil.exe dc123CEStarterSvc.exe

          what am I doing wrong?

          Thanks
          Attached Files

          Comment


          • #6
            Are you attempting to control the service name (dc123CEStaterSvc)? The error message looks as you are attempting to start the display name, but I could be wrong. Instead of posting screenshots inserted into docs, please attach the project file, or open a support ticket in the customer portal, attaching the file there, so I can have a proper look.

            Ulrich

            Comment


            • #7
              OK. I just created a ticket and included the files

              Comment


              • #8
                I have revised the project and gave you some pointers. I hope it helps.

                Ulrich

                Comment

                Working...
                X