views:

372

answers:

2

We have a NET app that gets installed to the Program Files folder. The app itself writes some files and creates some directories to its app folder. But when a normal windows user tries to use our application it crashes because that user does not have permission to write to app folder. Is there any folder in both WinXP and WinVista to which all users have writing permissions by default? All User folder or something like that? Thanks in advance

A: 

I'm not sure that there is a single path to which all non-administrator users have permission to write to.

I think the correct one would be <User>\Application Data

RickL
+2  A: 

There is no such folder.

But you can create one.

There is CSIDL_COMMON_APPDATA which in Vista maps to %ProgramData% (c:\ProgramData) and in XP maps to c:\Documents and Settings\AllUsers\Application Data

Feel free to create a folder there in your installer and set the ACL so that everyone can write to that folder.

Keep in mind that COMMON_APPDATA was implemented in Version 5 of the common controls library which means that it's available in Windows 2000 and later. In NT4, you can create that folder in your installation directory and in Windows 98 and below it doesn't matter anyways due to these systems not having a permission system anyways.

Here is some sample InnoSetup code to create that folder:

[Dirs]
Name: {code:getDBPath}; Flags: uninsalwaysuninstall; Permissions: authusers-modify

[Code]


function getDBPath(Param: String): String;
var
   Version: TWindowsVersion;
begin
  Result := ExpandConstant('{app}\data');
  GetWindowsVersionEx(Version);
  if (Version.Major >= 5) then begin
    Result := ExpandConstant('{commonappdata}\myprog');
  end;
end;
pilif
fantastic, this was exactly what I was looking for.
Robert P