cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
PlinyElder
Level 7

Use Property to set Shortcut Folder Name

Working with a Basic MSI application:

I am trying to have the Programs Menu folder name set dynamically with a Property. This will alow me to have the shortcut created with an MSI command line argument. I can hardcode the folder name in the msi but thats not what im looking for. Can i have the folder name be tied back to a Property in the Property Manager? [MYDIR] for example
Labels (1)
0 Kudos
(2) Replies
PlinyElder
Level 7

Anyone have any info?
0 Kudos
PlinyElder
Level 7

So i finally figured out a way to accomplish this. With help from this link

[LIST=1]
  • Create your new shortcut in your component
  • Keep note of the "Display Name" that Installshield defaults it to
  • Go to your Direct Editor. Go to the Directory table
  • Find your "Display Name" that was generated earlier. This will be under the "Directory" column
  • Rename it as a Public Property(ALL UPPERCASE). In my case i named it "STARTMENUFOLDER"
  • Change the Directory Parent to "ProgramMenuFolder"
  • Change the DefaultDir to "."
  • Change the ISAttributes to "0" (zero)
  • You will need to create a Custom action (SetStartMenuFolder) that has immediate execution and in in between "FileCost" and "CostFinalize"
  • Also i added the last bit of code to handle uninstalling of the shortcut. Installshield wont do this for you automatically. When i install my application i create a permanent registry key that holds the value of "START_MENU_FOLDER" and i read that in the uninstaller part and manually delete the shortcut and folder if empty.


    Then you will need to create a bit of Installscript code. This code will change the users selected start menu value in the installation database as well as remove the left over shortcuts and menu folder upon uninstall.

    export prototype SetStartMenuFolder(HWND);

    function SetStartMenuFolder(hMSI)
    STRING svREMOVE, szUserInput, szFullPath, svStartMenuGroup;
    INT iBufSize;
    begin
    MsiGetProperty(hMSI, "REMOVE", svREMOVE, iBufSize);

    if( svREMOVE != "ALL" ) then
    // Install Here
    MsiGetProperty(hMSI, "START_MENU", szUserInput, iBufSize);
    szFullPath = ProgramMenuFolder ^ szUserInput;
    MsiSetProperty(hMSI, "STARTMENUFOLDER", szFullPath);
    else
    // Manually remove the shortcut and folder
    MsiGetProperty(hMSI, "START_MENU_GROUP", svStartMenuGroup, iBufSize);
    DeleteFolderIcon( ProgramMenuFolder ^ svStartMenuGroup , "Server Manager" ); // Delete the Shortcut by its name
    DeleteDir( ProgramMenuFolder ^ svStartMenuGroup, ONLYDIR ); // Removes directory ONLY if it is empty
    endif;
    end;
  • 0 Kudos