Where is the guideline that says you shouldn't write to the Program Files area?

前端 未结 2 1404
别跟我提以往
别跟我提以往 2021-02-05 18:20

Many questions on SO say \"Windows developer guidelines\" or \"windows design guidelines\" say that you shouldn\'t write temporary or program data to the Program Files area, but

相关标签:
2条回答
  • 2021-02-05 18:51

    From Technical requirements for the Windows 7 Client Software Logo Program:

    Install to the correct folders by default

    Users should have a consistent and secure experience with the default installation location of files, while maintaining the option to install an application to the location they choose. It is also necessary to store application data in the correct location to allow several people to use the same computer without corrupting or overwriting each other's data and settings.


    Windows provides specific locations in the file system to store programs and software components, shared application data, and application data specific to a user:

    • Applications should be installed to the Program Files folder by default. User data or application data must never be stored in this location because of the security permissions configured for this folder (emphasis added)
    • All application data that must be shared among users on the computer should be stored within ProgramData
    • All application data exclusive to a specific user and not to be shared with other users of the computer must be stored in Users\<username>\AppData
    • Never write directly to the "Windows" directory and or subdirectories. Use the correct methods for installing files, such as fonts or drivers
    • In “per-machine” installations, user data must be written at first run and not during the installation. This is because there is no correct user location to store data at time of installation. Attempts by an application to modify default association behaviors at a machine level after installation will be unsuccessful. Instead, defaults must be claimed on a per-user level, which prevents multiple users from overwriting each other's defaults.

    And I'm quite sure that there's similar stuff for every Windows version of the NT family going back to Windows NT 4 or even earlier.


    See also this question.


    Edit: the original link in this post to the Windows 7 Logo program exists no more. Here you find the current link to the Certification requirements for Windows Desktop Apps. See Section 10, Apps must install to the correct folders by default

    0 讨论(0)
  • 2021-02-05 18:51

    In later versions of windows (Vista, 7 and of course server versions) access permission are restricted for "special folders" including "Program Files". Even if your program is elevated to have sufficient privileges to write to this folder it is still a bad idea.

    I don't know of any guidelines that state this but there is a list of special folders and what they are meant for. The fact that there is a special folder for nearly all types of data I can image means there is no need to use the program files folder.Special Folders list

    0 讨论(0)
提交回复
热议问题