Is there a folder in both WinXP and WinVista to which all users have writing permissions?

不羁岁月 提交于 2019-12-23 03:53:11

问题


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?


回答1:


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;



回答2:


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



来源:https://stackoverflow.com/questions/81686/is-there-a-folder-in-both-winxp-and-winvista-to-which-all-users-have-writing-per

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!