3

I'm writing a WiX installer for an application which was deployed previously using ClickOnce.

I would like to detect if the application was installed on the client computer and abort the MSI installation. I searched similar questions on Stack Overflow, but I couldn't find a way to do that.

If I can find a path or some registry key that tells me where the application was installed, I can abort the MSI installation via a Condition.

Using the answer for this question, I was able to get somewhere. The ClickOnce shortcuts are files with the .appref-ms extension. This is the code I use:

<Property Id="APP_CLICKONCE_INSTALLED">
    <DirectorySearch Id="dirSearch.APP.CLICKONCE" AssignToProperty="yes" Path="[StartMenuFolder]" Depth="2">
    <FileSearch Id="fileSearch.APP.CLICKONCE" Name="APP.appref-ms" />
    </DirectorySearch>
</Property>

<Condition Message="App is already installed. Please uninstall it then re-run this setup.">
    <![CDATA[APP_CLICKONCE_INSTALLED = "" OR INSTALLED]]>
</Condition>

However, StartMenuFolder gives the location for AllUsers profile, whereas the click once application is installed for the current user. I am still digging.

Using perUser installation the StartMenuFolder gives the current user location (I was using perMachine):

<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" />

All is good now.

1 Answer 1

5

I don't know anything about WiX, but another way to tell if a ClickOnce application is installed is to iterate through the uninstall strings in the registry, which are here:

HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall

You'll want to search for one where the product name of your application matches the Display Name for that set of keys.

Sign up to request clarification or add additional context in comments.

1 Comment

You are right, ClickOnce installers insert an entry in the Uninstall location (as any other Windows installer). The keys are different, but I can rely on DisplayName to find my application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.