Upgr. "Per-user only": Not suggesting already installed dir - Page 2 - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Upgr. "Per-user only": Not suggesting already installed dir

cosmin wrote:
All my custom actions are set to "immediate" - and all other options in "Execution Options" are deactivated, so I cannot choose anyway.
Where is the custom action scheduled? Note that the OLDPRODUCTS property is set during the "FindRelatedProducts" standard action.
Hello cosmin,

I have prepared and attached a small test case for the search. The custom action is scheduled after InstallExecuteSequence/CostFinalize.



With best regards

Clemens Anhuth
Attachments
Test_Search_for_OLDPRODUCTS.zip
Test case for searching for OLDPRODUCTS; create installer and install twice, the second time increase the version number, of course.
(1.94 KiB) Downloaded 282 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Upgr. "Per-user only": Not suggesting already installed dir

Hi,

It seems that OLDPRODUCTS is set after the search is performed, therefore the search doesn't find anything. Here is a sample VBScript custom action which does what you need:

Code: Select all

On Error Resume Next 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
      strComputer & "\root\default:StdRegProv") 

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall\" &_
	Session.Property("OLDPRODUCTS")
	
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, "InstallLocation", value
Session.Property("UPDATE_APPDIR") = value
Basically, this custom action does exactly what the search was supposed to do, except you can execute it whenever you want. Note that this code doesn't use any functions, therefore the "Function" field of this custom action should be empty.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Upgr. "Per-user only": Not suggesting already installed dir

cosmin wrote:It seems that OLDPRODUCTS is set after the search is performed, therefore the search doesn't find anything. Here is a sample VBScript custom action which does what you need:
Excellent, thank you very much! :)



With best regards

Clemens Anhuth
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Upgr. "Per-user only": Not suggesting already installed dir

cosmin wrote:It seems that OLDPRODUCTS is set after the search is performed, therefore the search doesn't find anything. Here is a sample VBScript custom action which does what you need:
In addition, note that OLDPRODUCTS gets set in the InstallUISequence/FindRelatedProducts, so do not try to use this script before this action.

Here is the script as JScript:

Code: Select all

var regKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + Session.Property("OLDPRODUCTS");

var HKLM   = 0x80000002;
var reg    = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv");
var method = reg.Methods_.Item("GetStringValue");

var inparams         = method.InParameters.SpawnInstance_();
inparams.hDefKey     = HKLM;
inparams.sSubKeyName = regKeyPath;
inparams.sValueName  = "InstallLocation";

var outparams = reg.ExecMethod_(method.Name, inparams);

if (outparams.ReturnValue == 0)
{
	var value = outparams.sValue;
	Session.Property("APPDIR") = value;
}


With best regards

Clemens Anhuth

Return to “Common Problems”