简体   繁体   中英

MSI Installer Data Properties

I'm playing around with MSI installation for a large project I'm working on and im intresting to know more about this properties that i see around.

They are things like [TARGETDIR] or anything wrapped in "[PROPERTNAMEHERE]". I'm trying to find out if their is a list of these anywhere?

On a side note, is there anyway to access all of these properties from a custom action. I've looked in the Context.Parameters collection but not seeing anything in there. I've been passing /name="[TARGETDIR]\\" as CustomActionData to a customaction but this isn't sufficient.

Thanks

Steve

Properties are very important to understand when working with MSI based packages. First of all you should know that there are two kind of properties, public properties and private properties . When working with custom actions you should always use public properties, to avoid their values getting reset when the install process passes from InstallUI Sequence to InstallExecute Sequence.

Also, very important , a custom action cannot get/set properties when running deferred. Only immediate, ie nondeferred, custom actions can get/set a property value.

There is one exception, when running a deferred custom action you can get the value from the special property called " CustomActionData ".

Now, in what regards the custom actions, you can write C++, C# or VBScript custom actions to get/set properties during the installation.

VBScript is not recommended for an official application release , but you can use it for something quick that you need to use inhouse.

For C++ custom actions you will get a DLL, from which you can export one or more methods, to call when your custom action is triggered. Please note that the function signature is different from standard DLLs, analyze the example linked carefully.

You can also get a similar DLL writing C# code , if that is more convenient.

It is very important to make sure you are not trying to run a standard DLL as a custom action , some commercial/free setup authoring tools support that too, but not all. If you plan to write a DLL custom action, its better you do it from the beginning using one of the two samples (C++/C#) linked above.

Seconds after I posted this I found what I'm looking for in regards to the property list: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx

Now I'm after a way to access these from code?

If you are using WIX...

To answer your side note first - you can access custom values from within a custom action (I'm assuming you know how to set up a custom action...) - look at your session object (parameter to the custom action) - this has a CustomActionData which has an indexer. Specify the name of the property you want to get out of it by specifying

session.CustomActionData["INSTALLLOCATION"]

You need to add the property to your custom action before you can access it however - and to do this you need to tell wix to set this up...

<CustomAction Id="UNIQUEID" Return="check" Property="YourCustomActionNameInWix" Value="INSTALLLOCATION=[INSTALLLOCATION]" />

To answer your other question - no I don't think you can get these values in code I have always had to script them.

HTH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM