We use the file lock test during install readyToInstallActionList stage to prevent installation while the app is running, and it works fine:

   <throwError>
        <text>${msg(Custom.AppInUse.Installer)}</text>
        <ruleList>
            <fileIsLocked>
                <path>${installdir}/instance.lok</path>
            </fileIsLocked>
        </ruleList>
    </throwError>

But this exact same action has no effect during the uninstall preUninstallationActionList stage:

   <throwError>
        <text>${msg(Custom.AppInUse.Uninstaller)}</text>
        <ruleList>
            <fileIsLocked>
                <path>${installdir}/instance.lok</path>
            </fileIsLocked>
        </ruleList>
    </throwError>

How can I make a similar check before uninstall and stop the uninstall until the app is not in use?

I have verified with Microsoft's Handle (Sysinternals) utility that the file is indeed locked.

asked 20 Dec '16, 11:39

cjw's gravatar image

cjw
113
accept rate: 0%


If an error is found during uninstallation, it is silently ignored and the uninstallation continues, although the rest of actions are not executed.

In this case you can use <exit exitCode="1"/> and <showWarning> in an <actionList> like in the following example:

  <preUninstallationActionList>
    <actionGroup>
      <actionList>
        <showWarning>
          <text>You must close the application ${project.fullName}
          before launching the uninstaller</text>
        </showWarning>
        <exit exitCode="1"/>
      </actionList>
      <ruleList>
         <processTest name="${project.fullName}.exe" logic="is_running" />
      </ruleList>
    </actionGroup>
  </preUninstallationActionList>
link

answered 22 Dec '16, 10:51

Michiel's gravatar image

Michiel ♦
74614
accept rate: 21%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×83
×14
×8
×3

Asked: 20 Dec '16, 11:39

Seen: 202 times

Last updated: 22 Dec '16, 10:51