Phil Pendlebury
Posts: 9
Joined: Tue Jan 15, 2008 9:44 pm

Place a file in AppData

Hi there,

I need to place a file in this folder:

C:\Users\USERNAMEl\AppData\Roaming\sberg\club\Presets\KeyCommands

The above is a Vista directory structure

For XP etc. I am not sure what the path is without checking I think it is:

C:\Users\USERNAMEl\Application Data\sberg\club\Presets\KeyCommands


Am I correct in thinking that I would place the file (in Advanced Installer) in the Application Data folder (maintaining the structure above)?

If so would it work with other systems? (XP etc.)
If so would it work with all languages?

Sorry if this seems dumb I am new to this.

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

Hi,

In order to install a file in the "Username\Application Data" folder you can use the "Application Data" folder in the "Files and Folders" page. If you need to install into a subfolder of Application Data, you must also create this subfolder in you Advanced Installer project.

Note that the "Application Data" folder in the "Files and Folders" page will be recognized on both XP and Vista platforms, no matter which language the operating system uses.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil Pendlebury
Posts: 9
Joined: Tue Jan 15, 2008 9:44 pm

Thank you for your answer.

A further question...

Is there way to tell Advanced Installer to place a file in a folder ONLY IF the folder tree already exists?

My application works on a variety of products and I need top place file in a certain folder depending on whether they have it installed or not.

For Example:

...AppData\Roaming\sberg\A\Presets\KeyCommands\*MYFILE*
...AppData\Roaming\sberg\B\Presets\KeyCommands\*MYFILE*
...AppData\Roaming\sberg\C\Presets\KeyCommands\*MYFILE*
...AppData\Roaming\sberg\D\Presets\KeyCommands\*MYFILE*

The user's computer only has the folder:

...AppData\Roaming\sberg\B\Presets\KeyCommands\


So I would in that case only want to put my file there NOT CREATING all the other folders.

Thanks for a wonderful product.

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

Hi,
Is there way to tell Advanced Installer to place a file in a folder ONLY IF the folder tree already exists?
This can be done by creating a search for this folder in the "Searches" page:
http://www.advancedinstaller.com/user-guide/search.html

Since the result of the search ends in a "\" character, you need to remove it. This can be done by using a VBScript custom action which looks like this:

Code: Select all

appdir = Session.Property("APPDIR") : Session.Property("MY_APPDIR") = Left(appdir, Len(appdir) - 1)
Now, you can use the property of the search (usually it's RESULT_PROPERTY) to create a property-based folder in the "Files and Folders" page. In this folder you can place the file you need.

In order to condition the installation of this file, you go to the "Organization" page and for the component of the file you add in the "Condition" field of the "Component Properties" page this condition:

Code: Select all

NOT (RESULT_PROPERTY ~>< "RESULT_PROPERTY")
Note that in this example "RESULT_PROPERTY" is the property of the search.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil Pendlebury
Posts: 9
Joined: Tue Jan 15, 2008 9:44 pm

Hi there,

Thanks again for your swift help. I have completed the installer now and it seems to work fine. the process was a little simpler than you described so I thought I should post it here for anyone else to reference. Also to be sure I have done it the correct way.

1. Search

Created a new search: LE4
[AppDataFolder]\Berg\LE 4\Presets\KeyCommands

Created 9 other searches all slightly different: CE 4 (etc.)
[AppDataFolder]\Berg\CE 4\Presets\KeyCommands
etc.

All set to a depth of 0 since I know exactly where the folder will be (if it exists).

2. Files and Folders

Created a new Property Based Folder for each search:

LE4, CE4 etc.

Dragged the file (keys.xml) I want to install to these folders (ONLY IF THEY ARE FOUND) to EACH folder. So the file had to be placed in my application's folder first otherwise it would not exist.

2. Organisation

I now have:

keys.xml
keys.xml_1
keys.xml_2

etc.

Select each one and depending on the value in "Directory" add the "condition":

NOT ([DIR NAME] ~>< "[DIR NAME]")

Example:

NOT (LE4 ~>< "LE4")

-----

That's it done.

It seems to work correctly. There seemed no need for VBscript. This maybe because it is a file I am installing that does not need a new folder creating.

I realise that I could do a deeper search for the folder I want to install to but there are two problems with that:

1. There are other folders at the same level with the name "KeyCommands"
2. Depending on what application is found the file (xml) has to be slightly different (a choice of two different ones actually).

I hope this helps a bit and maybe if you get chance you could look it over and see if I have done it in the most efficient way.

Thanks again.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
Select each one and depending on the value in "Directory" add the "condition":
NOT ([DIR NAME] ~>< "[DIR NAME]")
Please note that you are not using the names of the directories as a condition, you are actually using the properties used by the search. Advanced Installer sets the name of a property-based folder to the name of the property it uses.
It seems to work correctly. There seemed no need for VBscript. This maybe because it is a file I am installing that does not need a new folder creating.
Yes, you are right. If you just add files to the property-based folder Advanced Installer automatically handles the "\" character.
I realise that I could do a deeper search for the folder I want to install to but there are two problems with that:
1. There are other folders at the same level with the name "KeyCommands"
2. Depending on what application is found the file (xml) has to be slightly different (a choice of two different ones actually).
If you already know the paths of these folders there is no need to perform a deeper search for them. Since you use the search to find out if these folders exist or not, you have correctly configured your project.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phil Pendlebury
Posts: 9
Joined: Tue Jan 15, 2008 9:44 pm

Thank you Cosmin.

Yes I understood about the Directory naming (I named them similar to the actual directories that's all).

Your comments are greatly appreciated and hopefully may be some help to others too.

:-)

Best regards,

Phil.

Return to “Common Problems”