PDA

View Full Version : Using variables for shortcut names



prog24
12-09-2002, 08:55 AM
How could I make a shortcut based on a variable name. I want to make it from %ProductName%, but if I enter that, it makes that exact string the name. Is there a syntax to resolve this variable into it's value? I believe this requires a custom action, which modifies the msi shortcuts table, but I'm not sure how to do this. Any suggestions?

Thanks!!

Chandima
12-09-2002, 02:35 PM
I'm not sure if this will work but it's worth a try. Try renaming the shortcut to:

[ProductName]

Now build and install. Let me know if this works or not.

prog24
12-09-2002, 03:21 PM
Thanks for the reply. I tried that and got [ProductName] as the name of the shortcut.

thanks....

Chandima
12-10-2002, 11:26 AM
That's too bad. I guess it's hardcoding the value. You could always create your own shortcut through VBScript custom action but that means you will have to write another action to delete it. If interested try the following VBScript code:

Dim WshShell
set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")

ProdName = Session.property("ProductName")
InstDir = Session.property("INSTALLDIR")

set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & ProdName & ".lnk")
oShellLink.TargetPath = INSTALLDIR & "\MyFile.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save