سؤال

I developed an application for Windows, and now I need to configure the installer (I use NSIS). The program has binary files, which I install in C:\Program Files\<My App>\. It also requires user folder, which is important for users. This folder contains files that created by program, and users may want to use them frequently, and therefore to have easy access to this folder.

My question is what is the correct location of this user folder that would satisfy users with and without Admin privileges for all Windows versions starting from XP?

I've read this MS article. It describes codes of different locations, but it doesn't answer the question which one is correct. I tried to use ProgramData folder, but it turns out that this folder is hidden by default in Windows 8. Explaining users how to make it visible doesn't seem to be a good user experience.

هل كانت مفيدة؟

المحلول

The correct location is APPDATA if the files that need to be stored are different for each user or ProgramData if they are the same for all users. If you need your users to brwose the folder directly you can create folder shortcut next to your application shortcut, so you don't need to explain them how to make the folder visible on systems where it is hidden by default.

@Feco It is incorrect to store application files into Program Files folder, this is location that requires administrative privileges to write in, so NOT all users can write there. In Program Files folders you should only install your application binaries, if the application needs to be installed per-machine. If the application should be installed per-user, then APPDATA folder is the one.

Also, installing applications directly on "C:\" (Windows partition root) is an old habit, not standard practice. This has not advantages compared to installing the app in Program Files and just leads to cluttering your file system with various application folders on "C:\".

نصائح أخرى

Why don't you create an additional folder in your C:\Program Files\<My App> folder? All users have the necessary rights (read/execute) in there, and you can even point to this folder without referring to the drive itself with $PROGRAMFILES variable:

    SetOutPath $PROGRAMFILES\<My App>\userFolder

Users can then open the file from this place if they need to.

Alternatively you could install your My App program in root (in this example C:\) and create userFolder in it then change the rights to this folder via a batch file:

    SetOutPath $TEMP
    File "MyBatchFIle.bat"
      FileOpen $4 "$TEMP\MyBatchFIle.bat" w
        FileWrite $4 'icacls "C:\<My App>\userFolder" /grant Users:(OI)(CI)M'
      FileClose $4
    ExecWait "$TEMP\MyBatchFIle.bat"

this will grant Modify rights to all Users.

Here is a good guide for icalcs if you need different settings - http://technet.microsoft.com/en-us/library/cc753525.aspx

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top