Sunday, February 1, 2015

Unity: Install application into a writable folder on Windows OS with High UAC using Inno Setup

I have a Unity simulation program in which i need to create a Windows installer, I choose Inno Setup because it is free and easy to use. However, my Unity simulation program needs to writes simulation data and log data into the same folder when it is installed. Therefore the default program folder for installation is not preferred, because some users might have the UAC set to high in their Windows OS in which case the write permission in the program folder is not available.

After some thinking and a bit of search online, I found a simple way to do this. The trick it to create the installed directory in the AppData folder (one of its sub folder, e.g., Local, LocalLow, Roaming). This allows Unity simulation program installed there to write its data to the same folder even if user may have UAC set to high.

To do this with the Inno Setup. After generating the *.iss installation script in Inno Setup. Locate the line that starts with "DefaultDirName=". Now change it to "DefaultDirName={localappdata}\{#MyAppName}", Then build the installer. and the default installation path will be from the AppData/Local folder on the user's computer.