Vista: Defining "C:\ProgramData\MyCompany\MyApp" - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

janalphenaar
Posts: 18
Joined: Thu Jul 31, 2008 8:47 am

Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi,

I have just downloaded the latest trial version from the website (6.5.2) trying to build an MSI for Vista. The application is supposed to be installed in “C:\Program Files\MyCompany\MyApp” (APPDIR), which works perfectly.

To be compliant with Vista designing rules my configuration files should go into “C:\ProgramData\MyCompany\MyApp”. I know “C:\ProgramData” is in CommonAppDataFolder, but how can I append “\MyCompany\MyApp” to “C:\ProgramData" (without hard coding it)? Keep in mind that the user can change the location he wants the software to be installed (with the FolderDlg).

My question thus is: how can I dynamically set the value for “C:\ProgramData\MyCompany\MyApp”?

Warm regards,

Jan
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi Jan,

Advanced Installer uses the "Common Application Data" folder for the "CommonAppDataFolder" property. Therefore, if you want to install a file in the "C:\ProgramData\MyCompany\MyApp" folder, you can create the "MyCompany\MyApp" folders in the "Common Application Data" directory in the "Files and Folders" page. After the folders are created, you can place your files in the "Common Application Data\MyCompany\MyApp" folder.

Please note that the path of the "Common Application Data" folder is resolved automatically to the "ProgramData" folder.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
janalphenaar
Posts: 18
Joined: Thu Jul 31, 2008 8:47 am

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi Cosmin,

Thanks for your answer. This is kind of hard coding the path in Advanced Installer. Suppose I code the value “\MyCompany\MyApp” in the “Files and Folders” page as you say and the user decides to put the software in “C:\FineApp” with the FolderDlg. As a result of the hard coded string in AI my configuration files would still go in “C:\ProgramData\MyCompany\MyApp” in stead of “C:\ProgramData\FineApp”.

Regards,

Jan
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hello Jan,

you might be able to dynamically change the app data folder that your installation is going to use, but what would be the advantages and disadvantages?

By the way, is your installer going to put data into that common app data folder? What kind of data is it? Is it going to be changed?

I am asking because we put all files that aren't user-specific (and therefore, in our case, read-only) into APPDIR. At startup our application creates its app data folder and populates it.

(This approach has been decided upon to allow multiple users of the same computer to use our software while having their private settings, appdata, etc. We could try to create and populate an appdata folder for each user at the time of installation, but that seemed more error-prone, more complicated and wouldn't work for users created in the future; plus it would mean a considerable amount of disk space wasted for every user who is not going to use our software.)



With best regards

Clemens Anhuth
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi,
Suppose I code the value “\MyCompany\MyApp” in the “Files and Folders” page as you say and the user decides to put the software in “C:\FineApp” with the FolderDlg.
It seems that I missed the "FolderDlg" part of your post. Did you edit your first post by any chance?

In order to set the "Common Application Data" folder as the default installation folder, you can use the "Application Folder" field in the Install Parameters page. For example, you can set this field to:

Code: Select all

[CommonAppDataFolder][Manufacturer]\[ProductName]
After setting this field, you can place your files in "Application Folder" from the "Files and Folders" page. This way the default installation path will point to the "ProgramData" folder and the user will be able to change it.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
janalphenaar
Posts: 18
Joined: Thu Jul 31, 2008 8:47 am

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Cosmin,

No I did not change my original post, but I think you are missing my point; I will try to explain it a bit better.

In Vista we need to split the static binaries and dynamic configuration files in “C:\Program Files\MyCompany\MyApp” and “C:\ProgramData\MyCompany\MyApp” (Microsoft designing rules).

In the solution described in your last post everything would go into CommonAppDataFolder (including binaries) and that is not what I want to accomplish.

Let’s say the default value in FolderDlg is “C:\Program Files\MyCompany\MyApp”, all the configuration files would then go into “C:\ProgramData\MyCompany\MyApp”. But the user decided to change the default value to “C:\Program Files\FineApp”. In this case the binaries should go into “C:\Program Files\FineApp” and the configuration files should go into “C:\ProgramData\FineApp”.

If it is not possible to do this in Advanced Installer I guess I can always build the configuration files from my application at startup and remove the configuration files with a Custom Automation at removal.

Hope it is a bit clearer now.

Regards,

Jan
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi Jan,

I understand now. I'm afraid that what you need is not supported by Windows Installer or by Advanced Installer.

For most installation packages it doesn't matter what installation path is used for the application, the Product Name remains the same. Therefore, no matter what path the user sets in "FolderDlg", the application files will be installed in a folder which looks like this:

Code: Select all

C:\ProgramData\Manufacturer\ProductName
Please note that this is the approach recommended by Microsoft.

Perhaps you can use a custom action to set the path of a property-based folder based on the installation folder. However, I'm not sure if this would work as expected.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kevinfigg
Posts: 18
Joined: Mon Sep 08, 2008 3:46 pm

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

I'm in a similar situation to Jan.

I install my binaries to Program Files and want to save the config data to [commonappdata]

My intention is to have the normal installation path option for the binaries, and then ask the user where they want to store the data. The default value being the [CommonAppData]

Ive created another dialog with a folder selection which I will write to the registry for my Application to read. However, I cannot get AI to show the [CommonAppData] folder by default. If I enter the property of [CommonAppdata], the MSI says it can't find "[CommonAppData]" (String - not variable)

To get around this I have set the propery to be C:\MyData - hoping the user selects something more useful.

Is there a way of having the default folder path, of an extra dialog show the CommonAppData location (be it, C:\ProgramData or Doccuments and Settings\All Users)

Regards

Kevin Figg
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi Kevin,
Is there a way of having the default folder path, of an extra dialog show the CommonAppData location (be it, C:\ProgramData or Doccuments and Settings\All Users)
The recommended approach for this is to set the property of the custom Path Edit control to the value of the "CommonAppDataFolder" property. For example, if the Path Edit control on your custom dialog has the property "MY_PATH", you can use a "Property set with Formatted" custom action to set "MY_PATH" to the value of [CommonAppDataFolder].

This custom action can be scheduled under the "InstallUISequence" -> "Begin" standard action in order to set the property at the beginning of the install process. Please note that you can see a standard action by using the "Show Standard Action" button on the toolbar of the Custom Actions page.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kevinfigg
Posts: 18
Joined: Mon Sep 08, 2008 3:46 pm

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Thank you Cosmin. You are a genius. I've been stumped on that for a very long time.

Thanks again - much appreciated.
kevinfigg
Posts: 18
Joined: Mon Sep 08, 2008 3:46 pm

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Sorry Cosmin - one other thing.

The installer now shows the correct path in the textbox (in my custom dialog) to the [CommonAppDataFolder] location - which is great, exactly what I want.

However, I can't seem to get AI to write that value to the registry.

I have a standard registry value defined in HKLM/Manufact/Product called "DataPath". I have used a property I have created called 'SavePath' which is used by the Textbox as mentioned earlier to define the [CommonAppDataFolder].

For some reason, once the app has installed, the only value written to the registry is the Default value I entered when I created the property.

Any ideas to how I can write the value of the [CommonAppDataFolder] to the registry, keeping in mind the end user, when installing the product may change that location in my custom dialog.

Once again - many thanks

Kevin
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Hi,
I have a standard registry value defined in HKLM/Manufact/Product called "DataPath". I have used a property I have created called 'SavePath' which is used by the Textbox as mentioned earlier to define the [CommonAppDataFolder].
For some reason, once the app has installed, the only value written to the registry is the Default value I entered when I created the property.
Please note that private properties (they contain lowercase letters in their names) cannot pass their value from the UI (a dialog) to the execute sequence (when the registry entries are created). Therefore, you can try using a public property for your custom Path Edit control (for example "SAVE_PATH" instead of "SavePath").

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kevinfigg
Posts: 18
Joined: Mon Sep 08, 2008 3:46 pm

Re: Vista: Defining "C:\ProgramData\MyCompany\MyApp"

Thanks again Cosmin. Worked brilliantly. :D

Return to “Common Problems”