Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to get INSTALLDIR value in basic MSI project


9 replies to this topic

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 09 November 2011 - 12:11

Hi,

I want to pass INSTALLDIR value to one of my DLL which is used in the custom action. In Microsoft installer if you write [INSTALLDIR] it will get the value of installation directory, there [INSTALLDIR] is a custom action data. Do intallshield provide such kind of custom action data so that I can just assign that value to my parameter.

Thanks
Aditya

varunAdb

varunAdb
  • Full Members
  • 18 posts

Posted 10 November 2011 - 12:33

I didn't get your query.

However, this is how you read properties in custom actions(am assuming you understand the scope of the properties):
- for immediate custom actions, you can directly access the property using MsiGetProperty.
- for deferred/commit/rollback custom action, all properties are not directly accessible except for ProductCode, UserSID, and CustomActionData.
You can populate CustomActionData with value of property you want to access.
Say you have deferred custom action MyCADef. To access INSTALLDIR in this create a custom action of type 51 and set value of MyCADef to INSTALLDIR. Sequence this before MyCADef. Then you can access INSTALLDIR through CustomActionData.
When passing multiple properties, seperate by semi-colon and later tokenize in you CA.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 11 November 2011 - 06:07

Thanks

I have used the following KB article to get the value of INSTALL dir:

http://kb.flexerasof...DeferredCAs.htm

using thr above KB article I have written the following code snippet in my installscript:

function GetInstallDir(hMSI)

STRING installDirPath;

NUMBER installDirPathBuffer;

begin

installDirPathBuffer = MAX_PATH;

if(MsiGetProperty(hMSI, "CustomActionData", installDirPath, installDirPathBuffer) == ERROR_SUCCESS) then

SprintfBox(INFORMATION,"Deferred Execution","The value of INSTALLDIR is %s",installDirPath);

SprintfBox(INFORMATION,"Deferred Execution","The value of InstallScript's INSTALLDIR is %s", INSTALLDIR);

endif;

end;

When I run the installer first SprintBox show correct value but the other Sprintbox display blank.

Also, What exactly I want is, I have created on Deferred custom action in which I am calling one managed dll in which I have to pass INSTALLDIR value so, is it possible to pass the value of INSTALLDIR which I got from the above installscript?

Thanks

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 11 November 2011 - 06:48

Thanks

I have used the following KB article to get the value of INSTALL dir:

http://kb.flexerasof...DeferredCAs.htm

using the above KB article I have written the following code snippet in my installscript:

function GetInstallDir(hMSI)

STRING installDirPath;

NUMBER installDirPathBuffer;

begin

installDirPathBuffer = MAX_PATH;

if(MsiGetProperty(hMSI, "CustomActionData", installDirPath, installDirPathBuffer) == ERROR_SUCCESS) then

SprintfBox(INFORMATION,"Deferred Execution","The value of INSTALLDIR is %s",installDirPath);

SprintfBox(INFORMATION,"Deferred Execution","The value of InstallScript's INSTALLDIR is %s", INSTALLDIR);

endif;

end;

When I run the installer first SprintBox show correct value but the other Sprintbox display blank.

Also, What exactly I want is, I have created one Deferred custom action in which I am calling one managed dll in which I have to pass INSTALLDIR value so, is it possible to pass the value of INSTALLDIR which I got from the above installscript?

Thanks

varunAdb

varunAdb
  • Full Members
  • 18 posts

Posted 11 November 2011 - 15:50

Exactly, that is what the kb is trying to illustrate. Since you get a blank message means INSTALLDIR is not accessible directly in deferred CA. To make it accessible pass it through CustomActionData.

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 14 November 2011 - 05:09

Hi Varun,

Thanks for your reply.

Can you please tell me how to pass it through CustomActionData. Sorry, I am new installshield.

Thanks
Aditya

AlexLX

AlexLX
  • Full Members
  • 27 posts

Posted 15 November 2011 - 21:01

The steps are mentioned in the link that you have mentioned:

"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.
"

aditya1685

aditya1685
  • Full Members
  • 31 posts

Posted 24 November 2011 - 07:32

Thanks Guys issue has been solved smile.gif

JaiShankarVurimi

JaiShankarVurimi
  • Full Members
  • 2 posts

Posted 11 April 2012 - 08:09

Hi Aditya,

I am trying to get the INSTALLDIR value to delete all the left over files in the user installed path.
I have followed the steps in the below link, but still could not achieve.
http://helpnet.flexe....eferredCAs.htm

I am getting just blank space only.

Could you provide more details to read INSTALLDIR value.

Thanks in advance

Regards
Jaishankar

JaiShankarVurimi

JaiShankarVurimi
  • Full Members
  • 2 posts

Posted 11 April 2012 - 12:11

Hi,

- My goal is to delete all the application created files after uninstallation.
- To acheive this i was trying to get the INSTALLDIR value through deferred custom action as per the below link.
http://helpnet.flexe...DeferredCAs.htm

- My Configurations:
1. Create a set-a-property custom action (type 51) called GetINSTALLDIR
Property Name: DisplayINSTALLDIR
Property Value: [INSTALLDIR]
Install Exec Sequence: After InstallInitialize

2. In the InstallScript view, create a new function called DisplayINSTALLDIR with the below code.

export prototype DisplayINSTALLDIR(HWND);
function DisplayINSTALLDIR(hISWI)
STRING szInstDir;
NUMBER nvCount;
begin
nvCount = MAX_PATH;
if (MsiGetProperty(hISWI,"CustomActionData",szInstDir,nvCount) = ERROR_SUCCESS) then
SprintfBox(INFORMATION,"Deferred Execution","The value of INSTALLDIR is %s",szInstDir);
SprintfBox(INFORMATION,"Deferred Execution","The value of InstallScript's INSTALLDIR is %s",INSTALLDIR);
endif;
end;

3. In the Custom Actions and Sequences view, created an InstallScript custom action called DisplayINSTALLDIR.
Function Name: DisplayINSTALLDIR
In-Script Execution: Deferred Execution in System Context
Install Exec Sequence: After GetINSTALLDIR

My Output:
The values of szInstDir & INSTALLDIR in the above 2 message boxes are blank.

Other Observation:
When tried the same as instructed in the link (http://helpnet.flexerasoftware.com/installshield18helplib/AccessingProps-DeferredCAs.htm) i am getting a blank message for the first messagebox & a code for the 2nd message box.

Could you please guide me.

Thanks & Regards
Jaishankar.