This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Basic MSI Project - Custom Action - unable to get installed path
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 20, 2017
01:06 AM
Basic MSI Project - Custom Action - unable to get installed path
Hi,
I am using InstallShiled 2014 Pro.
I have created Basic MSI Project.
Added CustomAction in Basic MSI Project. ( Call a function in a Windows Installer dynamic-link library )
PFA: Screenshot for more info
https://i.imgsafe.org/1b4b0f3066.png
Added the new property in property manager.
Name - CustomActionData
Value - [INSTALLDIR]bin
When I executed setup.exe then "Install" custom action has thrown.
I am unable to get installed path.
shared custom action dll source code.
[CODE]
UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionData"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}
[/CODE]
I got "[INSTALLDIR]bin" instead of "installed path" value in the message.box.
I am using InstallShiled 2014 Pro.
I have created Basic MSI Project.
Added CustomAction in Basic MSI Project. ( Call a function in a Windows Installer dynamic-link library )
PFA: Screenshot for more info
https://i.imgsafe.org/1b4b0f3066.png
Added the new property in property manager.
Name - CustomActionData
Value - [INSTALLDIR]bin
When I executed setup.exe then "Install" custom action has thrown.
I am unable to get installed path.
shared custom action dll source code.
[CODE]
UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionData"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}
[/CODE]
I got "[INSTALLDIR]bin" instead of "installed path" value in the message.box.
- Tags:
- customaction
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 24, 2017
10:32 AM
It's been a long time since I used C++ for a Custom Action. I always use C# these days. But see if this information helps
https://social.msdn.microsoft.com/Forums/windows/en-US/93ff80f2-3968-4a69-a123-e0bf079052f5/how-to-get-installdir-with-msi-and-custom-action-dll?forum=winformssetup
The passing of [TARGETDIR] into CustomActionData seems to have been the trick in this case.
I hope that helps.
Chad
https://social.msdn.microsoft.com/Forums/windows/en-US/93ff80f2-3968-4a69-a123-e0bf079052f5/how-to-get-installdir-with-msi-and-custom-action-dll?forum=winformssetup
The passing of [TARGETDIR] into CustomActionData seems to have been the trick in this case.
I hope that helps.
Chad
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 24, 2017
09:06 PM
To pass a value as CustomActionData, you need to set a property that matches the name of the custom action. In your case, set the value of the property named CustomActions to [INSTALLDIR]bin.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 27, 2017
02:05 AM
Hi chad.petersen
Thanks for reply
Please addressed my following steps.
1.
I have added a custom action in merge module.
PFA: screenshot has more info.
https://i.imgsafe.org/afb61dba52.png
2.
I have added Property in Property Manager in merge module.
PFA Screenshot for more info.
https://i.imgsafe.org/afd2ad7396.png
3.
I have added merge module in basic MSI Project.
4.
I have added the custom action from merge module in basic MSI project.
PFA: screenshot for more info.
https://i.imgsafe.org/afdda9c8e0.png
I have shared sample source code of dll
[CODE]
UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionsForInstall"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
I have set CustomActionName = PropertyName in merge module.
Please verify my install sequences of custom action.
I have set all property as per your instruction but it is not working now.
Regards,
Vijay Kumbhani
Thanks for reply
Please addressed my following steps.
1.
I have added a custom action in merge module.
PFA: screenshot has more info.
https://i.imgsafe.org/afb61dba52.png
2.
I have added Property in Property Manager in merge module.
PFA Screenshot for more info.
https://i.imgsafe.org/afd2ad7396.png
3.
I have added merge module in basic MSI Project.
4.
I have added the custom action from merge module in basic MSI project.
PFA: screenshot for more info.
https://i.imgsafe.org/afdda9c8e0.png
I have shared sample source code of dll
[CODE]
UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionsForInstall"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
I have set CustomActionName = PropertyName in merge module.
Please verify my install sequences of custom action.
I have set all property as per your instruction but it is not working now.
Regards,
Vijay Kumbhani
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 27, 2017
01:55 PM
The value of the property that matches the name of your custom action is available in the CustomActionData property within the deferred, commit, or rollback custom action. You need to get the value of the the CustomActionData property as your original code did:
[CODE]UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionData"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
[CODE]UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionData"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 29, 2017
11:13 PM
Hi Hidenori Yamanishi,
please explain what is/are the meaning of commit & rollback in "In-script execution" in the custom action.
I also tried with deferred and immediate execution in "In-script execution" in the custom action but it unable to get installed path.
You said to me in the previous reply. (01-25-2017, 08:36 AM - Post Number - #3 )
CustomAction Name and Property key both are same.
I had applied to set same of CustomAction Name and Property key.
Example:
CustomActionName: "CustomActionForInstall"
PropertyKey = "CustomActionForInstall".
I also changed MSI DLL code.
[CODE]UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionsForInstall"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
Please read my (01-27-2017, 01:35 PM Post Number - #4) and tell me
what is/are wrong?
please explain what is/are the meaning of commit & rollback in "In-script execution" in the custom action.
I also tried with deferred and immediate execution in "In-script execution" in the custom action but it unable to get installed path.
You said to me in the previous reply. (01-25-2017, 08:36 AM - Post Number - #3 )
CustomAction Name and Property key both are same.
I had applied to set same of CustomAction Name and Property key.
Example:
CustomActionName: "CustomActionForInstall"
PropertyKey = "CustomActionForInstall".
I also changed MSI DLL code.
[CODE]UINT __stdcall Install( MSIHANDLE hInstall )
{
TCHAR customData[MAX_FILE_PATH * 3];
DWORD len = sizeof( customData ) / sizeof( TCHAR );
UINT gp = ::MsiGetProperty( hInstall,
_T("CustomActionsForInstall"),
customData,
&len);
::MessageBox(NULL, customData, "Install", MB_OK);
if (gp != ERROR_SUCCESS)
{
return ERROR_INSTALL_FAILURE;
::OutputDebugString("gp != ERROR_SUCCESS");
}
return ERROR_SUCCESS;
}[/CODE]
Please read my (01-27-2017, 01:35 PM Post Number - #4) and tell me
what is/are wrong?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 30, 2017
09:11 AM
Deferred, commit, and rollback custom actions in Basic MSI and InstallScript MSI installations have access to only some of the built-in Windows Installer properties: CustomActionData, ProductCode, and UserSID. If you want a custom action to access any other properties during deferred, commit, or rollback execution, you can pass them as CustomActionData. You can do so by scheduling an immediate set-a-property type of custom action to set a property that matches the name of the custom action. The value of this property is then available in the CustomActionData property within the deferred, commit, or rollback custom action.