cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jhopkins
Level 3

Shortcut folder name based on property

Hi,

I am using an evaluation copy of IS 2012 and I am trying to create some folders in the shortcut menu, but one of them should be based on a property. So my shortcut should be located in "Programs Menu\My Company\My Program\[ProductVersion]\". However the folder named [ProductVersion] does not evaluate to the product version. How do I get this functionality?

The reason I want this functionality is so that I can have multiple versions of the same program.

Thanks.
Labels (1)
0 Kudos

(6) Replies
Christopher_Pai
Level 16

It's not easy. Unfortunately the underlying Windows Installer database schema ( Shortcut table ) doesn't support formatting that column.

The only two ways I know how to do it are:

1) Use a custom action to emit temporary records into the table at install time and allow MSI to create the shortcut

2) Use custom actions to create and remove the shortcuts yourself.
0 Kudos
jhopkins
Level 3

Okay. I've been looking through your blog recently and I'm using WiX for C# integration but so far I haven't done anything with the database. Assuming I go with 1) are there any good resources you could point me to on accomplishing this?

Thanks for the help.
0 Kudos
Christopher_Pai
Level 16

Checkout my article:

http://blog.deploymentengineering.com/2008/07/dynamic-windows-installer-ui.html

Now assuming that your MSI builds a Shortcut table.... ( it gets messier if you need to create the table. It's best to have something, even a fake component with a no-op component condition so that it never gets installed, that has a Shortcut to make sure the table exists.

Use the static InsertRecord function from my blog like this.

InsertRecord(
session,
"Shortcut",
new object[]
{
"emittedShortcut1",
"DesktopFolder",
session["MyShortCutNameProperty"],
"MyComponent",
"[#somefilekey]",
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
});
0 Kudos
jstarbird
Level 5

I actually did exactly what you're trying to do, set the version as the Folder name in Programs Menu. It's actually not that complicated as the other answers given.
What you do is create a Custom Actions to set a Directory. I used a Directory Name of SHORT_CUT_VER_FLDR, then set the Directory Value to [ProgramMenuFolder]\[Manufacturer]\[ProductName]\[ProductVersion] .
Then set that to run just after Cost Finalize, I set it there for Install UI and Install Exec with it set to Execute Only Once.
Then in the Shortcut properties, Select that Folder you wish to name to the version and in the KEY NAME enter the Directory Name above, SHORT_CUT_VER_FLDR.
That's it. Works great for me.

Hope that helps,
J
0 Kudos
jhopkins
Level 3

Thanks J. Got it working quite easily from that.

The custom action I wrote from Christopher's suggestion executed without errors, but for some reason the shortcut wasn't created.

Thanks for the help guys!
0 Kudos
Christopher_Pai
Level 16

I just realized that I speed read this post. If you only want the same shortcut name but in a different directory, then yes, use a Type 51 or Type 35 custom action to redirect the directory table entry to the desired location.

However, if you need to have transformed shortcut names in the same directory ( DesktopFolder MyApp-Prod MyApp-Test for example ) then the only way is what I described.

I tested the code that I wrote. It's a very clean way of doing it because you are still leverage MSI's standard actions for creating and removing the shortcuts. If it's not working for you, make sure you are emitting the row in the Shortcut table correctly. One of the disadvantages of dynamic MSI authoring at install time is you lose all of your ICE validation capabilities so you must be certain to do it 100% correctly.
0 Kudos