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

Creating Custom ProgramFiles folder

I am using Installshield 2014 and im working in an Installscript MSI Project. I am also new to Installshield and working with a demo to learn the application. Help is greatly appreciated

[LIST=1]
  • I am creating a simple install that contains the "SelectFolder" dialog BEFORE the "SdAskDestination" dialog
  • The user can either take the defaulted Program Folder, which i have set OR create their own folder name
  • Once the user sets their custom name and clicks Next, they see the "SdAskDestination" dialog. The path is updated and correctly display the custom folder name the user entered in the previous step
  • Once the installation takes place, all the shortcuts get installed into the default folder name that was set NOT the custom name the user entered into the "SelectFolder" dialog.
  • From what i can see in the help docs, the "CreateProgramFolder" function must be created in a custom script and executed in sequence. I am unsure how to do this so far or maybe im missing a step somewhere else.


    Where do i go from here?

    Thanks
  • Labels (1)
    0 Kudos
    (11) Replies
    Evan_Border
    Level 8

    PlinyElder wrote:
    I am using Installshield 2014 and im working in an Installscript MSI Project. I am also new to Installshield and working with a demo to learn the application. Help is greatly appreciated

    [LIST=1]
  • I am creating a simple install that contains the "SelectFolder" dialog BEFORE the "SdAskDestination" dialog
  • The user can either take the defaulted Program Folder, which i have set OR create their own folder name
  • Once the user sets their custom name and clicks Next, they see the "SdAskDestination" dialog. The path is updated and correctly display the custom folder name the user entered in the previous step
  • Once the installation takes place, all the shortcuts get installed into the default folder name that was set NOT the custom name the user entered into the "SelectFolder" dialog.
  • From what i can see in the help docs, the "CreateProgramFolder" function must be created in a custom script and executed in sequence. I am unsure how to do this so far or maybe im missing a step somewhere else.


    Where do i go from here?

    Thanks


  • With InstallScript MSI it's not enough to only call SelectFolder. You also need to set the value for the new folder name. There are a couple of ways to do it, but probably the easiest is to use the MsiSetProperty InstallScript function to set the value for your Start Menu folder:



    In the above screenshot the SelectFolder and MsiSetProperty functions are being called directly before the SdAskDestPath function (in the OnFirstUIBefore function).

    In order for this to work, your Start Menu folder must be a Public Property (all uppercase letters in the Directory column of the Directory table). Otherwise Windows Installer will ignore your new folder name (because MSI "private properties" throw away their value and re-initialize using their default value when switching from Immediate Mode to Deferred Mode).

    To make that more clear, here's what my Directory table looked like when I created my Start Menu folder:



    Notice in the screenshot above that the name in the Directory column of the Directory table contains lowercase letters. That makes it a Windows Installer "private property", which is a big problem if the goal is to alter the folder name.

    So I performed a search-and-replace in the Direct Editor view and made sure that it used only uppercase letters (which makes it a Windows Installer "public property"):



    Performing those steps should allow the user to modify the name of the Start Menu folder. Note: You may need to also take steps to guarantee that the uninstall properly removes the shortcut and Start Menu folder, otherwise they may get orphaned.
    0 Kudos
    PlinyElder
    Level 7

    Evan Border wrote:

    With InstallScript MSI it's not enough to only call SelectFolder. You also need to set the value for the new folder name. There are a couple of ways to do it, but probably the easiest is to use the MsiSetProperty InstallScript function to set the value for your
    Performing those steps should allow the user to modify the name of the Start Menu folder. Note: You may need to also take steps to guarantee that the uninstall properly removes the shortcut and Start Menu folder, otherwise they may get orphaned.


    So this works perfectly except when it comes to the uninstalling of the shortcuts/start menu folder(Which you noted). So do i need custom script to handle the uninstall process or can the uninstaller reference that Public Property using an "Add File Removal" process?
    0 Kudos
    Evan_Border
    Level 8

    PlinyElder wrote:
    So this works perfectly except when it comes to the uninstalling of the shortcuts/start menu folder(Which you noted). So do i need custom script to handle the uninstall process or can the uninstaller reference that Public Property using an "Add File Removal" process?


    Yes, I would typically record the user's custom folder choice in a registry entry and have the uninstall read that registry entry. No custom action is needed...you should be able to use Windows Installer's built-in System Search capability to read in the registry (where you stored the custom folder name) Ex:







    As long as you are setting the property to the same name as the directory table entry (NEWFOLDER1 in my example), Windows Installer handles the rest for you.
    0 Kudos
    PlinyElder
    Level 7

    OK, thank you for the info. I havent gotten to try this yet but i am not in the world of the Advanced Suite UI. So if i am trying to do this in the Advance Suite then i have to add the MSI package that contains the installation of my application. BUT is the secondary MSI aware of the Suite UI folder selection?
    0 Kudos
    Evan_Border
    Level 8

    PlinyElder wrote:
    OK, thank you for the info. I havent gotten to try this yet but i am not in the world of the Advanced Suite UI. So if i am trying to do this in the Advance Suite then i have to add the MSI package that contains the installation of my application. BUT is the secondary MSI aware of the Suite UI folder selection?


    If you're using a suite and having the user choose their custom start menu folder name via a Suite dialog, you'll want to pass that as a command line option to your MSI. In my example, I made sure that the folder was a MSI public property (named NEWFOLDER1), so I would have the suite call my MSI and add "NEWFOLDER1=[whatever variable name my Suite is using for the custom folder that the user chose]"

    So you'd go to the Property Manager view in your Suite and add whatever property name you want to use for that, setting it to a reasonable default value. You'd then set up a custom dialog in the Wizard Interface view that makes use of that property. On the Packages view, you'd add a command line to your MSI that makes use of the property.

    0 Kudos
    PlinyElder
    Level 7

    So sorry to bring this back up but im trying to do this in pure Installscript and its not working. Im guessing because its using MsiSetProperty in a non MSI project?

    How can i set the custom folder when in an Installscript project?
    0 Kudos
    Evan_Border
    Level 8

    PlinyElder wrote:
    So sorry to bring this back up but im trying to do this in pure Installscript and its not working. Im guessing because its using MsiSetProperty in a non MSI project?

    How can i set the custom folder when in an Installscript project?


    Just get rid of that MsiSetProperty command. It's only for InstallScript MSI's.
    0 Kudos
    joshstechnij
    Level 10 Flexeran
    Level 10 Flexeran

    FeatureSetTarget can be used to set folder paths. Note that this function works for both InstallScript and InstallScript MSI projects.
    0 Kudos
    PlinyElder
    Level 7

    Evan Border wrote:
    Just get rid of that MsiSetProperty command. It's only for InstallScript MSI's.


    So i must still be missing something. Since the MsiSetProperty is now gone, how am i pushing this value back to the entry in my Directory table? In my Directory table i have a value called 'NEWFOLDER' with a generic defaultdir called 'MyApp' but in my Installscript code there is not a way that i see to reference or set the value for 'NEWFOLDER'. My call to SelectFolder is as follows:


    nResult = SelectFolder(szTitle, svDefGroup, svResultsFolder);


    When the installation is run, doesn't matter what the user enters for the start menu folder name the folder is ALWAYS created as 'MyApp'
    0 Kudos
    PlinyElder
    Level 7

    joshstechnij wrote:
    FeatureSetTarget can be used to set folder paths. Note that this function works for both InstallScript and InstallScript MSI projects.


    I'm not getting the desired result from trying to set the ProgramFiles folder path with FeatureSetTarget. :confused:


    Dlg_SdSelectFolder:
    nResult = SelectFolder(szTitle, svDefGroup, svValue);
    FeatureSetTarget( MEDIA, "", svValue );

    if ( nResult = BACK ) goto Dlg_SdFeatureTree;


    My Directory Table below:


    My Folder im trying to have the dynamic name on:
    0 Kudos
    PlinyElder
    Level 7

    So i ended up figuring this out after about 4 days of working on it. This is the method that i used:


    • Setup Design View - Click the shortcuts Folder
    • Create new Programs Menu Folder
    • In the new folder, set the Display Name property to
    • In my installscript code set the SHELL_OBJECT_FOLDER variable to svResultFolder


    Works perfectly without having to create custom code for uninstall. Its all handled automatically by the installer
    0 Kudos