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
- :
- Re: MsiGetTargetPath problem
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
‎Sep 25, 2018
11:33 AM
MsiGetTargetPath problem
Hi, I'm quite new with InstallShield and currently working on my first project (using InstallShield 2018 Professional), so I'm running into lots of trouble. Currently I'm stuck with MsiGetTargetPath and even searching this forum couldn't find any solution.
Quick problem setup:
I have a Basic MSI project. In Properties I've defined a property called "MAINDIR". The value is looked up from registry: In RegLocator I read a value into regSignatureMaindir, in AppSearch I connect it to the MAINDIR property. Generally, looking up the Property results in the correct path, so this part works as expected.
In Directory view, directories are defined as follows (besides several other standard directories):
The "Target Directory Path" preview shows [MAINDIR] for the first entry and [MAINDIR]\tools for the second. Looks alright to me.
In my InstallScript Custom Action I try this:
Unfortunately, svToolsdir is always empty. Just for a test, I also tried to look up MAINDIR instead, same result: MsiGetTargetPath returns an empty string.
In other Custom Actions, for example type "Launch an executable", I can use TOOLSDIR as working directory and also reference [TOOLSDIR] in "File Name & Command Line", it works perfectly. Generally it seems the properties are set up correctly.
Is there anything I missed, any property I'd have to set for MsiGetTargetPath?
Edit:
Just some more information: Within the same InstallScript method I also can't look up the properties using MsiGetProperty; I get an empty result.
In "Custom Actions and Sequences" view the custom action is set as "Synchronous (Check exit code)" and execution "Deferred Execution in System Context". Install Exec Sequence: After WriteIniValues. Just in case it matters.
Quick problem setup:
I have a Basic MSI project. In Properties I've defined a property called "MAINDIR". The value is looked up from registry: In RegLocator I read a value into regSignatureMaindir, in AppSearch I connect it to the MAINDIR property. Generally, looking up the Property results in the correct path, so this part works as expected.
In Directory view, directories are defined as follows (besides several other standard directories):
Directory Directory_Parent DefaultDir
-----------------------------------------
MAINDIR TARGETDIR MAINDIR
TOOLSDIR MAINDIR tools
The "Target Directory Path" preview shows [MAINDIR] for the first entry and [MAINDIR]\tools for the second. Looks alright to me.
In my InstallScript Custom Action I try this:
nvSize = MAX_PATH + 1;
MsiGetTargetPath(hMSI, "TOOLSDIR", svToolsdir, nvSize);
SprintfMsiLog("Tools dir is %s.", svToolsdir);
Unfortunately, svToolsdir is always empty. Just for a test, I also tried to look up MAINDIR instead, same result: MsiGetTargetPath returns an empty string.
In other Custom Actions, for example type "Launch an executable", I can use TOOLSDIR as working directory and also reference [TOOLSDIR] in "File Name & Command Line", it works perfectly. Generally it seems the properties are set up correctly.
Is there anything I missed, any property I'd have to set for MsiGetTargetPath?
Edit:
Just some more information: Within the same InstallScript method I also can't look up the properties using MsiGetProperty; I get an empty result.
In "Custom Actions and Sequences" view the custom action is set as "Synchronous (Check exit code)" and execution "Deferred Execution in System Context". Install Exec Sequence: After WriteIniValues. Just in case it matters.
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 25, 2018
12:03 PM
If your custom action is executed in "Deferred Execution in System Context", then you should read this:
Obtaining Context Information for Deferred Execution Custom Actions
regards
Markus
Obtaining Context Information for Deferred Execution Custom Actions
regards
Markus
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 26, 2018
10:19 AM
MarkusLatz wrote:
If your custom action is executed in "Deferred Execution in System Context", then you should read this:
Obtaining Context Information for Deferred Execution Custom Actions
regards
Markus
I agree with Markus if your action needs to be a run in deferred mode. If you are trying to get the value of a property, which a directory identifier is, I would think that it could (and should) be done in immediate mode, thereby eliminating the need to deal with CustomActionData. If you make this change, schedule that action to run after CostFinalize and before InstallInitialize.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 26, 2018
11:09 AM
Thanks very much to both of you!
The hint from Markus brought the solution. I need the deferred action because after getting the property, some changes will be made to the system and according to the documentation, those cases should always be deferred actions.
Now just fighting with support files, but that might be another story another time...
The hint from Markus brought the solution. I need the deferred action because after getting the property, some changes will be made to the system and according to the documentation, those cases should always be deferred actions.
Now just fighting with support files, but that might be another story another time...