How to install files to "All Users\Documents"? - 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!

topper_harley
Posts: 24
Joined: Fri Aug 24, 2007 1:13 pm

How to install files to "All Users\Documents"?

Hi there!

I need to install files to "\Documents and Settings\All Users\Documents" (XP) respectively "\Users\Public\Documents" (Vista).
I chose this folder because under Vista it's the only one that can be read-write-accessed by all users and enable all users to share the same file (other folders like the "ProgramData" will be virtualised :x )

Is there any easy way to install files in this folder?

How can I access this folder in a custom action script?
In the application the folder location can be get by the Windows-API-function SHGetSpecialFolder(), but I could not find any matching scripting function for that on MSDN (fso.GetSpecialFolder() wouldn't do this)...

TIA
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi ,

I'm afraid that Windows Installer doesn't offer any property for Common Documents folder. So you will have to use a custom action to achieve what you want.

In order to install in that folder you could use the following approach:

1. Define a property in "Install Parameters" view and then create a property based folder in "Files and Folders" view.

2. Add you files in this folder.

3. Create a DLL custom action will set the value of the defined property to the path of the Documents folder. In order to get this path you can use the SHGetFolderPath method with CSIDL_COMMON_DOCUMENTS.

http://msdn2.microsoft.com/en-us/library/ms647764.aspx

After you have set the property from the DLL custom action you can then retrieve it from the script using session.property method.

The custom action should be scheduled before CostFinalize on both UI and Execute sequences. Also be sure that the "Execute only once if preset in both sequence tables" option is set.

Hope this helps.

Regards,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
topper_harley
Posts: 24
Joined: Fri Aug 24, 2007 1:13 pm

I thought it would be something like that. Sounds kinda easy :D

Ok, I have a DLL with a function that returns the folder I'm looking for.

But how do I get the function result into my installer property?
What do you mean with "DLL custom action"? I took the custom action wizard that produced a "Attached Custom Action". So far so good, I set the source path to my DLL and filled the function name. But how does the DLL set the property?
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

What do you mean with "DLL custom action"
By this I mean an attached custom action that executes a function from a DLL.
But how does the DLL set the property?
In order to set the value of a property you can use the MsiSetProperty method.

http://msdn2.microsoft.com/en-us/library/aa370391.aspx

Please see the following link for more details on DLL custom actions:
http://msdn2.microsoft.com/en-us/library/aa368338.aspx

Regards,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
jabibo
Posts: 1
Joined: Thu Feb 28, 2008 4:01 pm

Hello,

I have exactly the same issue. Installing files in vista, which can be accessed and changed from all users seems to be not so easy. As there are some new security-"features" in vista I thought "vista-ready" meant the advanced Installer would support these issue.
OK - now to my problem: I should write a DLL which returns the correct Path in a string. As I am not a real c or c++ programmer I would like to ask, if there is such a DLL (has to run under Win 2K, XP and Vista) or maybe just the source code....?

Any help or suggestions are welcome.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

I'm afraid that we do not have a sample custom action for this.

However, you can place your files in the "Common Application Data" folder in the "Files and Folders" page. This folder uses the CommonAppDataFolder property which is resolved at runtime to the "All Users\Application Data" folder.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
wyzerd
Posts: 75
Joined: Tue Mar 27, 2007 3:54 am
Location: St. Louis, MO
Contact: Website

Re: How to install files to "All Users\Documents"?

While SHGetFolders is fine, I prefer Looking up the Shell folders from the registry. It seems alot more straight forward to me.

Here is the vbs to do the job:

Code: Select all

option explicit
public function GetAllDoc()
   dim objShell, strAllDoc
   set objShell=CreateObject("WScript.Shell")
   'SHGetFolders is really a simple query to the "Shell Folders" key...
    strAllDoc=objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Documents")
   set objShell = nothing
   Session.Property("CommonDocuments")=strAllDoc
   GetAllDoc=strAllDoc
end function
Place it under InstallExecuteSequence On Begin
glmdev
Posts: 14
Joined: Thu Aug 06, 2009 4:07 am
Location: Witten, Germany

Re: How to install files to "All Users\Documents"?

A good Idea!

I have found a way to use this idea without using a vb script. Just take a look to my posting on http://www.advancedinstaller.com/forums ... 704#p25354

Kind regards,
Christof Konstantinopoulos,
Germany

Return to “Common Problems”