How to give a standard user write permission to a folder in Program Files

In Windows Vista, Windows 7 and Windows 8 the Program Files folder and the Program Files (x86) folder (and all subfolders beneath) are read-only folders for standard users (users that run programs with standard privileges). This means it is not possible for them to create files or update files in this location of the hard disk. The folders are write-protected. Why these folders are write-protected is explained in this technical article on our website.

The 'Program Files' and 'Program Files (x86)' folder

We sometimes get the question: is it possible to circumvent the write protection and allow also standard users write access to a folder beneath Program Files and Program Files (x86)?

The answer is: Yes, it is possible. You can do it by changing the permission settings for the folder.

This should always be the last resort if you can not find another way. All folders placed in Program Files and Program Files (x86) should be write-protected for standard users, but sometimes this can give problems to older legacy software. In some computers a virtualization system called VirtualStore can solve the problem, but in many computers this is turned off. And then it is impossible to write data to a file. A file can be neither created nor updated.

You should note that it requires a user with administrator rights to change the permission settings for a folder in Program Files and Program Files (x86). A standard user can not change any permissions.

How do I change the permission settings for a folder?
This can be done in different ways. One method is just to right click on the folder in Windows Explorer, choose the Properties menu item, open the Security tab, select the Users item and change permissions for the user.

The 'Properties' dialog box in Windows

Although this is achievable, this is not a user-friendly solution for end-users. Especially not for users that are not so familiar with computers. A much better method is to change the permissions programmatically.

Let the installation program change the permission settings
As mentioned above, the permissions should be changed programmatically, and the best method is to let the installation program change the permission settings. When a software is installed to the Program Files / Program Files (x86) folder, the setup program is always run with administrator rights. This means that the installation program is allowed to change permission settings for a folder. If you try to change the permission settings later, for example when the installed software is running, it is very likely that the software do not have administrator rights. It will very likely only have standard user access rights, and it can therefore not change any permission settings for folders in Program Files / Program Files (x86).

How Visual Installer can handle this
In our setup tool Visual Installer there is a special script command that can be used to change permission settings for a folder. The name of the command is SETPERM, and below you can see an example of how to use the script command:

The 'Execute script commands' dialog box in Visual Installer

%DESTDIR\MyDataFolder is a path to a folder that will have its permissions changed and PERM_ALL tells Visual Installer to give a standard user full access rights to the folder (including write access). Instead of PERM_ALL you can also use PERM_WRITE as a second parameter. PERM_WRITE will give the standard user write access to the folder, but no other permission settings are changed.

%DESTDIR is variable that contains the main destination folder for the installation. If for example the main destination folder is C:\Program Files\SamLogic\My Application, the full path to the folder entered above will be C:\Program Files\SamLogic\My Application\MyDataFolder.

Related information
> How to install files in the correct folder using Visual Installer
> Visual Installer’s Scripting Language

Leave a Reply