Setting File and Folder Permissions using Inno Setup
So, what I have learned for today?
In the past days, I was bothered with this limitations of one of the softwares that we created. The software does not allow users who don’t have adminisrative privilages to write, delete and modify files and folders in the Program Files Folder. In short, only the administrator or some limited users, who have admin privilages, can use the software. This is pretty much annoying and impractical for a commercial software like we are doing.
So, how do I solved this problem?
My first approach is to know if there is a Borland C++ function that set the file and folder permissions upon creating it. But it wasn’t a success since borland c++ only have a function for determining the file attributes, whether it is read only, hiden or archive. It can also change the attributes but doing such things need an adminitrative level privilages. So, therefore, any C++ functions cannot change the permissions if the user is not an administrator.
My second and the successful approach is to set permissions during installation process, and it can only be done in the set up compiler, the Inno Setup. Inno setup is the most popular setup compiler. Some claim that it is better than any commercial set-up compilers, but the other important thing about Inno Setup is that it is free and open source. The output of Inno Setup is a compiled executable installation file. The configuration of the installation file can be set or modify in the source code. In case of my problem, the file permissions can be set using the following code:
[Dirs]
Name: “{app}\”; Permissions: everyone-modify
The above code simply means that during the installation process, the folder where the executable file and other files are located, everyone has the permissions to create new file and delete or modify existing files and subdirectories. So easy, huh? But that 2 line code took me 3 hours to learn.
Filed in: Software











