cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TimoZimmermann
Level 5

Getting the value of [#filekey] in InstallScript

I have a Basic MSI Project and uses a custom InstallScript Action.
How can I evaluate the value of the property [#filekey] in InstallScript. MsiGetProperty (hMSIHandle, "#filekey", szReturn, nvBuf) does not work. :confused:

[#filekey] is replaced by the full path of the file, with the value filekey used as a key into the File table, e.g. as a value of a regestry entry or used as a command line for a custom action and so on.

More infos to formatted values:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368609(v=vs.85).aspx
Labels (1)
0 Kudos
(11) Replies
rrinblue22
Level 9

Does that qualify as a property?
I just tried to set a property in Property manager (manually in the IDE) with #TEST and that doesn't allow me to do.....
0 Kudos
Christopher_Pai
Level 16

You need to call MsiFormatRecord().

[CODE]#include "ifx.h"

export prototype MyFunction(HWND);

function MyFunction(hMSI)

NUMBER nvBufferSize;
STRING svPropertyValue, svResult;
HWND hRecord;

begin

nvBufferSize = MAX_STRING;
hRecord = MsiCreateRecord(0);
MsiRecordSetString(hRecord, 0, "[#notepad.exe]");

nvBufferSize = MAX_STRING;
MsiFormatRecord(hMSI, hRecord, svResult, nvBufferSize );
MessageBox( svResult, INFORMATION);

return ERROR_SUCCESS;

end;[/CODE]
0 Kudos
RobertDickau
Flexera Alumni

You could create a set-property custom action that sets MYFILEPATH to [#sample.exe] and then use MsiGetProperty to get MYFILEPATH; or call MsiFormatRecord.
0 Kudos
Christopher_Pai
Level 16

Hehe, that's cheating. Course as fun as C/C++/InstallScript make calling MSI API, I could understand why you'd do this. (See my example above.)

In C#/DTF it's a bit simpler:

[CODE]
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
string filePath = session.Format("[#notepad.exe]");
return ActionResult.Success;
}
[/CODE]
0 Kudos
Roman1
Level 9

and what about Script, please?
0 Kudos
Christopher_Pai
Level 16

What kind of Script?
0 Kudos
TimoZimmermann
Level 5

RobertDickau wrote:
You could create a set-property custom action that sets MYFILEPATH to [#sample.exe] and then use MsiGetProperty to get MYFILEPATH; or call MsiFormatRecord.


Thanks Christopher and Robert. Both suggestions work...
0 Kudos
Roman1
Level 9

Hi Christopher,
how to realize it using IS-Script, please?
0 Kudos
Christopher_Pai
Level 16

My reply above (message #3 in the thread) is an InstallScript answer.
0 Kudos
Roman1
Level 9

yes. Thanks.
0 Kudos
Christopher_Pai
Level 16

You are welcome.
0 Kudos