Tech Tip: Running 4D Applications from the "Program Files" Folder
PRODUCT: 4D | VERSION: 12 | PLATFORM: Win
Published On: September 23, 2011
Since Windows Vista (i.e. including Windows Server 2008 and Windows 7) Microsoft has made certain folders "protected" in Windows. In order to write to these folders there are two choices:
- The application must run with "elevated" privileges.
- All write modifications will be made to a Virtual Store instead of the actual file location
For 4D this particularly pertains to installing databases and/or merged applications to the "Program Files" folder (or "Program Files (x86)" for 32-bit applications installed on 64-bit Windows). This folder is one of the protected folders in Windows. Typically applications are not supposed to write to this folder. Obviously 4D databases cannot meet this requirement; furthermore merged applications contain the database files which must definitely remain modifiable.
Note that this does *not* apply installations of only the 4D software. 4D applications (4D, 4D Server) can be safely installed to protected folders because they do not modify themselves. This only applies to databases and merged applications installed to a protected folder.
If the 4D database/merged application must be installed to Program Files, here is a description of the possible options.
ElevationTo run the application with elevated privileges, right-click on the executable and select "Run as Administrator". This will allow 4D to write to the Program Files folder (and any other protected folder):
To make this step permanent, right-click on the executable and select Properties. Then switch to the "Compatibility" tab and enable "Run this program as an Administrator":
PLEASE NOTE: elevating the privileges of 4D will cause a UAC prompt to be displayed every time 4D is launched.
Virtual StoreIf an application attempts to write to a protected folder without elevated privileges, the write will occur in a "Virtual Store" instead of the target folder. A Virtual Store is simply a different, non-protected location for the files to exist. On Windows 7, for example, the Virtual Stores are located at:
Here is an example you can try of creating a new 4D database in Program Files without elevated access:
- Launch 4D.
- Create a new database, select the Program Files folder and give it a name.
- Open Windows Explorer and navigate to the Program Files folder. Notice your database is not here!
- Locate your "VirtualStore" folder and open the "Program Files" folder you find there.
- You've found your database!
Note that this is totally transparent to the application. As far as 4D is concerned the files are located in Program Files.
ChallengesEach solution presents its own set of challenges.
Running with elevated privileges presents a potentially annoying UAC prompt each time the program runs.
Using Virtual Stores can get very messy. In the example above, the database isn't even located where intended. What if the database was already installed to Program Files? This situation is potentially worse; a copy of the files will be made in the Virtual Store and all subsequent modifications will be made to the copy, not the original. If a user goes looking for the database files, they will need to check the virtual store for the latest version.
RecommendationBecause of the above challenges, we recommend not installing 4D databases and/or merged applications to protected folders. We recommend, in general:
- If the application must be installed per-user, install it within the User's folders (i.e. in the "My Documents" folder).
- If the application can be installed per-machine, place it at the root of the drive (in its own folder of course).