cancel
Showing results for 
Search instead for 
Did you mean: 
jlabrie
Pilgrim

Location for common data under Vista

Hi,

in our software, we have a configuration file that is per-machine i.e. we want all the potential users to see the same file and potentially edit it (a monitor utility, that run on behalf the user, can also change it ). Before Vista, the file was located with the program (under Program Files). With Vista, we want to move it elsewhere (as the install creates the file as system and thus is read-only for the user). We used the FOLDER_COMMON_APPDATA directory but we seem to encounter some problem as it is a hidden directory. In the Win 32 API, there seems to be a special path CSIDL_COMMON_DOCUMENTS that should do the trick, but it is not available within InstallScript or the components.

Am I missing something or is there another way to achieve this so the file can be read/write for all users under Vista.

thanks
Labels (1)
0 Kudos
5 Replies
Not applicable

Re: Location for common data under Vista

CommonAppData corresponds to the folder C:\ProgramData on Vista machines.

CSIDL_COMMON_DOCUMENTS is a path not provided by default. But I believe if you search on this forum, you will find sufficient information to get it working in your installation.
0 Kudos
davbrown2
Pilgrim

Re: Location for common data under Vista

I also encountered this issue, and solved it by writing a custom action in C

// Installer helper file
//
// MSI custom actions

// GetCommonDocs: sets MSI property to the value returned by SHGetFolderPath(CSIDL_COMMON_DOCUMENTS)

#include "stdafx.h"
#include


#include "stdtypes.h"

#include
#include "drsetup.h"
#include
#include
#include

#include
#include



char szPath[256], svName[256];
CString messageString, titleString;


void __stdcall GetCommonDocs(MSIHANDLE hWnd)
{



UINT retcode;


if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_COMMON_DOCUMENTS|CSIDL_FLAG_CREATE,
NULL,
0,
szPath)))
{
// MessageBox(NULL, szPath, "GetFolder", MB_OK|MB_TASKMODAL);


retcode = MsiSetProperty (hWnd, "COMMON_DOCUMENTS", szPath);

// if ( MsiSetProperty (hWnd, "COMMON_DOCUMENTS", szPath) != ERROR_SUCCESS )
// {
// MessageBox(NULL, "Problem calling MsiSetProperty()", "GetFolder", MB_OK|MB_TASKMODAL);
// }

if (retcode == ERROR_FUNCTION_FAILED )
MessageBox(NULL, "MsiSetProperty() - The function failed.", "GetFolder", MB_OK|MB_TASKMODAL);
if (retcode == ERROR_INVALID_HANDLE )
MessageBox(NULL, "MsiSetProperty() - An invalid or inactive handle was supplied.", "GetFolder", MB_OK|MB_TASKMODAL);
if (retcode == ERROR_FUNCTION_FAILED )
MessageBox(NULL, "MsiSetProperty() - An invalid parameter was passed to the function", "GetFolder", MB_OK|MB_TASKMODAL);



}
else
{
MessageBox(NULL, "ShGetFolderPath Failed", "GetFolder", MB_OK|MB_TASKMODAL);
}


}
0 Kudos
dandraka
Pilgrim

Re: Location for common data under Vista

jlabrie wrote:
Hi,

in our software, we have a configuration file that is per-machine i.e. we want all the potential users to see the same file and potentially edit it (a monitor utility, that run on behalf the user, can also change it ). Before Vista, the file was located with the program (under Program Files). With Vista, we want to move it elsewhere (as the install creates the file as system and thus is read-only for the user). We used the FOLDER_COMMON_APPDATA directory but we seem to encounter some problem as it is a hidden directory. In the Win 32 API, there seems to be a special path CSIDL_COMMON_DOCUMENTS that should do the trick, but it is not available within InstallScript or the components.

Am I missing something or is there another way to achieve this so the file can be read/write for all users under Vista.

thanks


We have the same issue with our software and we used a subfolder named COMPANYNAME under FOLDER_COMMON_APPDATA.

The folder is hidden indeed, but for the case the user needs to access it, we have a shortcut under Start -> All programs -> Program Shortcuts folder. So far it's working great, and I think it's the correct way to go.

Why is it a problem that the folder is hidden, other that the users cannot find it (if they do not have "show hidden files" checked in folder options) ?
0 Kudos
jlabrie
Pilgrim

Re: Location for common data under Vista

dandraka wrote:
We have the same issue with our software and we used a subfolder named COMPANYNAME under FOLDER_COMMON_APPDATA.

The folder is hidden indeed, but for the case the user needs to access it, we have a shortcut under Start -> All programs -> Program Shortcuts folder. So far it's working great, and I think it's the correct way to go.

Why is it a problem that the folder is hidden, other that the users cannot find it (if they do not have "show hidden files" checked in folder options) ?


We have encountered a situation where we had a problem with the file that is copied there. After an uninstall/reinstall, the file was not copied there for some reason. But, we also have some output files generated at that location where a shortcut is not ideal (the user must find it with the Explorer)
0 Kudos
jlabrie
Pilgrim

Re: Location for common data under Vista

thanks for the help.

I finally used a call to the SHGetFolderPathA from within the InstallScript (the code was in another community thread) and everything seems to be working fine.
0 Kudos