Posts

Showing posts with the label Custom Action

VBScript to determine Root Drive

As per best practices we should not hard code the Root Drive in our package. If your package goes to multiple machines having different Root Drives, then you can use this simple VBScript in your package as Custom Action and it will set the Root Drive automatically for that machine. This script picks up the Root Drive from where Program Files folder is installed. Set oshell=CreateObject("Wscript.shell") prog=oshell.ExpandEnvironmentStrings("%ProgramFiles%") vletter=Split(prog,":") dletter=vletter(0) & ":\" session.property("ROOTDRIVE")=dletter

Different Ways of Giving Permissions in Your Windows Installer

Image
Windows XP/Windows 7 works under a locked down environment in most organisations. The MSI authors generally have to provide permissions to the installation directory, so that the users without admin rights are able to access and write data into the installation directory. When you set permissions, you are specifying what level of access the user has to the folder and its files and what users can do within that folder such as save, delete, or read files. If you would like to know how to set permissions through Powershell Script, then I would recommend you to read my new blog entry here: http://msiworld.blogspot.com/2012/01/my-first-powershell-script.html There are six standard permission types which apply to files and folders in Windows XP/Windows 7: Full Control Modify Read & Execute List Folder Contents Read Write Each level represents a different set of actions users can perform. See the table below for more information. For folders you can also set your own unique permission...

Using SOURCEDIR Property in Package

SOURCEDIR property in MSI package refers to the location from where the MSI is installed in the machine. How do we use this property in our package. If you want to use a file which is kept in the source folder (next to where your MSI is placed), through Custom Action then you need to follow this procedure. The SOURCEDIR cannot be directly used in the package. If you read the logs then SOURCEDIR property is created and correctly pointed to the directory. But later the log shows that: Deleting SOURCEDIR... So the value of this property is deleted and the MSI does not get access to it. If you display message with [SOURCEDIR] property then it will be empty. The work around for this is that we can put an Action in the sequence called: "ResolveSource" after CostFinalize action. Then if you place your Custom Action after this action which refers to SOURCEDIR property then you will get the correct value of SOURCEDIR. Acknowledgement: I would like to thank my friend, Anurag, here who ...

Isolation of a File: Two Ways in One MSI

Generally you would have read that after isolation is done, we should not modify the MSI. So how to do .local and .manifest in the same MSI. Actually you would be thinking: "What is the need to do both types in the same MSI?" This is because, recently, I came across a situation in which we needed to do isolation of a file for installation of application in Windows 2000 through .local method and for installation in Windows XP and Vista through .manifest method. This was needed to be done through same MSI. This is the solution. Create a .msi file with .local isolation method for windows 2000. Then create another .msi file with .manifest isolation. Note the visual difference of .manifest isolation file and the base MSI. Make all the differences seen in this to the .msi which was created with .local isolation. Then compile it. This will not get corrupted. Only the ones with .manifest isolation if recompiled again get corrupted. So take care of this and you can then conditionalize...

Using VBScript to Set Properties in MSI

We can easily use Set Property Custom Action to set Windows Installer Property, but sometimes we wish to set the property directly in VbScript, specially if we are taking an input from a user through VBScript. Hope this tip helps. To set property through VBScript we can use "Session" object like: Session.Property("ALLUSERS")="1" or we can directly use Property keyword like: Property("REBOOT")="ReallySuppress" The only catch here is that we cannot set INSTALLDIR property through the above method as the package uses Directory table to store the value of INSTALLDIR. We need to write the below VBScript to set INSTALLDIR: dim instpath instpath = "C:\newpath\newfolder" Session.TargetPath("INSTALLDIR")=instpath Remember to place this Custom Action after CostFinalize if you are changing the value of INSTALLDIR property in UI Sequence.

Easy way of Copying Condition in Custom Action

Image
I have learnt an easy way of copying condition directly in one Custom Action from other. This is totally on my experience, and I have not found any material for it on net too. So here it goes... Suppose you are making a CustomAction2 and have added it in the sequence as shown : And now you have to mention the condition same as that of CustomAction1, which in this case is "NOT Installed AND NOT PATCH", you have to click on CustomAction1 in the sequence and it will be like this: You can see the Condition in the greyed area. You cannot copy it directly, but what you have to do is: go to any of the other tab from this situation, be it Properties or Details tab. All you have to do next is to come back to your Location tab. And here you see the result.The Condition is automatically copied to the CustomAction2. Go ahead and try this out. It is really fun and easy. It will save you some time too.

Why Custom Action Type 51 is Required

If you have always wondered why we need to anSet Property Custom action when there is already a Property table to handle it, then this is for you. Suppose we have to create a property based on the value of another property - in that case we cannot use the Property table to handle this. There will be a circular reference in which one property would be based on the other. In this scenario we use Set Property Custom Action. To affect a property used in a condition on a component or feature, the custom action must come before the CostFinalize action in the action sequence.

Property passing in Custom action

If you want to pass property or a directory in Custom action then u can use Set Property Custom Action and place it after Cost Finalize. Name the property with the name of the Custom Action you want to pass it to. Then you can retain this property in Custom Action by Session.Property, If you are running this Custom Action in Deffered mode then you need to pass parameter as CustomActionData and if you are running this CA in Immediate Execution then you need to directly pass the property name.You can pass more that one property, by set property CA, by separating it with ";"Also while retrieving these valuues you need to split the variable in you retrieved from Session.Property.