LynnRW
29th July 2008 20:38 UTC
Setting File permissions
I'm writing an installer for an application used by several different users who log onto the Win-XP at different times.
I use the following code (+ more) and everything works OK for me. However if another user logs-on, they get "can't write file..." errors in the Log directory, etc.
InstallDir $PROGRAMFILES\MyApp
CreateDirectory "$INSTDIR\Bin"
CreateDirectory "$INSTDIR\Logs"
I know I can make the Shortcuts available to ALL-users, but how can I give All-users the necessary file permissions?
Thanks for your help.
Lynn
nsnb
29th July 2008 20:49 UTC
I am a newbie, don't know much yet, but I think that what you're looking for is SetShellVarContext :
Sets the context of $SMPROGRAMS and other shell folders. If set to 'current' (the default), the current user's shell folders are used. If set to 'all', the 'all users' shell folder is used. The all users folder may not be supported on all OSes. If the all users folder is not found, the current user folder will be used. Please take into consideration that a "normal user" has no rights to write in the all users area. Only admins have full access rights to the all users area. You can check this by using the UserInfo plug-in. See Contrib\UserInfo\UserInfo.nsi for an example.
Chris
KrisAster
29th July 2008 21:25 UTC
LynnRW, can another user navigate to that location? It seems that they have read access to execute the application, but it seems that it is trying to write a file to that location. Is this what you'd like to happen? Most applications in today's Vista / XP world probably shouldn't be writing files (or opening files with those permissions) to '\Program Files' directory. Customarily, the files a program would want to write are program settings and the like, which would be better stored in a user's directory (ie C:\Documents and Settings\<username>\Application Data\<Your program>).
That being said, I think that the 'AccessControl' plugin might be what you're looking for.
LoRd_MuldeR
29th July 2008 22:15 UTC
In order to support multi-user OS properly (e.g. WinXP), your application should be prepared that the user, who runs the application, might have limited access rights. Hence your application might run with limited access rights! Therefore user-specific data should be saved to "C:\Documents and Settings\John Doe\Application Data\My Program" and data that applies to all users should be saved at "C:\Documents and Settings\All Users\Application Data\My Program". If you need to save data at a different location, a privileged user with Admin rights is required...