- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Automatically set INSTALLDIR to the same value for base version and major upgrade
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Automatically set INSTALLDIR to the same value for base version and major upgrade
Automatically set INSTALLDIR to the same value for base version and major upgrade
1. Create a base version with the custom action "SetARPINSTALLLOCATION" (refer to the project settings in the screenshot and alter Install
Exec Condition based on your product needs).
Note: The custom action created in the base version will help in setting the INSTALLDIR in the Windows Registry, which will allow you to retrieve the INSTALLDIR when you start installing the major upgrade.
2. Install to the desired path on the target machine, a path other than default path.
3. Now create major upgrade by incrementing the product version (for example, from version 1.0.0 to version 2.0.0), generating a new product code with the ellipsis {…} button, adding a major upgrade item under upgrades and with two new custom actions listed below:
- InstallScript custom action with the below settings associated with respective InstallScript code (Please alter Install Exec Condition based on your product needs).
InstallScript associated with READINSTALLLOCATION
export prototype ReadInstallLocation(HWND); function ReadInstallLocation(hMSI) STRING szKey, szName, svValue, svPropertyValue; NUMBER nvType, nvSize, nvBufferSize; begin RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); szKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{9D9E6191-A7D8-455A-9177-531471683FC8}"; szName = "InstallLocation"; nvType = REGDB_STRING; nvSize = MAX_PATH; nvBufferSize = MAX_PATH; RegDBGetKeyValueEx(szKey,szName,nvType,svValue,nvSize); MessageBox("svValue="+svValue,INFORMATION); MsiSetProperty(hMSI,"MYINSTALLLOCATION",svValue); MsiGetProperty(hMSI,"MYINSTALLLOCATION",svPropertyValue,nvBufferSize); MessageBox("svPropertyValue="+svPropertyValue,INFORMATION); end;
- New Set Directory Custom Action:
Now create the build and Install on the target machine it will retrieve the INSTALLDIR of the program and set it as default path automatically during installation of the major upgrade.
Attached is the sample of the project created for your reference.
- New Set Directory Custom Action: