I've used something like the following in the past:
Write a custom action that uses MsiEnumProductsEx and if it finds the product
call a error message that you author into the error table.
Here is some sample code. Assume all the usual disclaimers. :)
UINT __stdcall CheckForPreviousRelease (MSIHANDLE hMsi)
{
UINT uiStatus = ERROR_SUCCESS;
WriteToLog( hMsi, _T("Entering CheckForPreviousRelease function"));
uiStatus = MsiEnumProductsEx(
_T("{GUID OF PRODUCT YOU ARE SEARCHING FOR GOES HERE}"), // ProductCode
of the previous release
_T("s-1-1-0"), // search all users
MSIINSTALLCONTEXT_USERMANAGED | MSIINSTALLCONTEXT_USERUNMANAGED |
MSIINSTALLCONTEXT_MACHINE, // search all users
0,
NULL,
NULL,
NULL,
NULL);
switch (uiStatus)
{
case ERROR_SUCCESS:
{
WriteToLog(hMsi, _T("Product found: {GUID}"));
break;
}
case ERROR_BAD_CONFIGURATION:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_BAD_CONFIGURATION"));
break;
}
case ERROR_ACCESS_DENIED:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_ACCESS_DENIED"));
break;
}
case ERROR_MORE_DATA:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned ERROR_MORE_DATA"));
break;
}
case ERROR_UNKNOWN_PRODUCT:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_UNKNOWN_PRODUCT"));
break;
}
case ERROR_INVALID_PARAMETER:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_INVALID_PARAMETER"));
break;
}
case ERROR_NO_MORE_ITEMS:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_NO_MORE_ITEMS"));
break;
}
case ERROR_FUNCTION_FAILED:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned
ERROR_FUNCTION_FAILED"));
break;
}
default:
{
WriteToLog(hMsi, _T("MsiEnumProductsEx returned unknown return
value"));
break;
}
}
if (uiStatus == ERROR_SUCCESS) // Previous release was found. In this
context, it is considered an error because we want the install to cease.
{
MSIHANDLE hError = MsiCreateRecord(1);
MsiRecordSetInteger(hError, 1, 2001); // Use code 2001 from the msi's
Error table. (Author this in the wix file.)
MsiProcessMessage(hMsi, INSTALLMESSAGE_ERROR, hError);
WriteToLog( hMsi, _T("Leaving CheckForPreviousRelease function"));
return ERROR_INSTALL_FAILURE;
}
else // we didn't find the previous release so the install should continue
{
WriteToLog( hMsi, _T("Leaving CheckForPreviousRelease function"));
return ERROR_SUCCESS;
}
}
-----Original Message-----
From: Wilson, Phil [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2008 2:47 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] ALLUSERS property and upgrades
Hang on - scratch that. FindRelatedProducts will fail because of the
per-user/per system stuff. D'oh! That leaves you the Rob impersonation choice.
Phil Wilson
-----Original Message-----
From: Wilson, Phil
Sent: Wednesday, December 03, 2008 2:45 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] ALLUSERS property and upgrades
The Upgrade stuff is good at detecting specific versions of installed products
using UpgradeCode. That can be used to set a property if the product is found.
There's a potential sequencing issue because FindRelatedProducts is what
detects previous versions, so I'd use a type 19 custom action sequenced after
FindRelatedProducts conditioned on the property in the Upgrade search (that's
set to only detect).
If there's a specific component guid unique to that previous version, then
(impersonating Rob) I'd do a ComponentSearch for that component guid, then that
property can be used in a launch condition.
Phil Wilson
-----Original Message-----
From: Colin Bleckner [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2008 2:34 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] ALLUSERS property and upgrades
That's unfortunate, thanks for confirming that for me though. Any idea how
to craft a Condition element that's based on a previous installation's
Product's Version setting?
On Wed, Dec 3, 2008 at 2:11 PM, Ian Elliott (Excell Data Corporation) <
[EMAIL PROTECTED]> wrote:
> I think you are stuck with the dialog option. Per-user can only uninstall
> that user, and per-machine can only uninstall per-machine, AFAIK.
>
>
> -----Original Message-----
> From: Colin Bleckner [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2008 1:38 PM
> To: General discussion for Windows Installer XML toolset.
> Subject: [WiX-users] ALLUSERS property and upgrades
>
> A previous version of my installer erroneously included a ALLUSERS property
> line:
> <Property Id='ALLUSERS' Value='1' />
>
> I tried taking it out in my new installer (I want the application to be
> installed on a per-user basis) but noticed that installing over an old
> version no longer removes the previous installation. Searching the mailing
> list looks like RemoveExistingProducts only uninstalls previous versions
> who's ALLUSERS value match the current installer's version. Is there a way
> to force the installer to uninstall a previous version, regardless of it's
> ALLUSERS value? Or am I forced to pop up a dialog telling the user they
> need to manually uninstall previous versions first?
>
> Thanks,
> Colin
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> WiX-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> WiX-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users