Inno Setup won't install to "Program Files" on Win 7 for limited user

4.5k Views Asked by At

Per the subject... I made a Setup.exe with Inno Setup which is supposed to install to "{pf}{#MyAppName}". It does so on Win XP and also Win 7 if I'm logged in with admin rights, but if I try on Win 7 as a limited user, I get this error message:

"Setup was unable to create the directory C:\Program Files\AppName".

What to do? I don't want (or need) the user to install as an admin.

1

There are 1 best solutions below

2
On BEST ANSWER

If you want to install to %ProgramFiles%, you do need to install as an admin. Regular users don't have write access to %ProgramFiles% directory.

If installing to %ProgramFiles% is not a requirement, just let the user pick a destination directory, or install to {localappdata} instead of {pf}. {localappdata} is guaranteed to be writable for it's owner. It expands to something like C:\Users\<user name>\AppData\Local.

You can also install to {pf} if running as admin and to {localappdata} if running as restricted user; use IsAdminLoggedOn to decide.

If installing to %ProgramFiles% is a must, you have no choice but to run as admin. For this to work correctly, make sure that your .iss file either does not define PrivilegesRequired option, or it's set to admin. Then, when an unprivileged user runs the installer, a UAC prompt will appear asking for credentials with enough access rights (unless UAC is disabled, in which case the only way to install is Run As).