0

I'm working on a project with a SQLite database. It works fine in my Visual Studio project. When I try to deploy using Inno Setup the MyApp.exe cannot write (Read Only) the database file in the folder ProgramData.

If I run the setup by Right-Click > Run as Administrator the MyApp.exe is then capable of writing the database file.

So I added the admin permission using PrivilegesRequired=admin But it still doesn’t work.

I can't figure-out:

  1. Why MyApp.exe cannot write a file in ProgramData except running the setup as Admin?
  2. Why this PrivilegesRequired=admin code doesn't work?

My Operating System is Windows 10 and I'm logged in as the admin. My Inno Setup compiler version is 5.6.1.

[Setup]
PrivilegesRequired=admin 

[Files]
Source: "{#SourceFolder}MyApp.exe"; DestDir: "{app}"
Source: "{#SourceFolder}Database.db"; DestDir: "{commonappdata}\MyApp"; Flags: ignoreversion 

I can give to MyApp.exe to admin permission in C# code, but still need to work this app in a non-admin account

samgi
  • 198
  • 11
  • 1
    That is accurate. Counter to popular opinion, content in c:\programdata is read-only to non-elevated users. Your installer can write to it because installers always run elevated, but your program does not. The default install of Windows does not encourage different users overwriting each other's data. Use AppData for a single user, but for multiple users you'd have to create a directory with the necessary write access privilege. [Permissions section](http://www.jrsoftware.org/ishelp/index.php?topic=dirssection). – Hans Passant May 07 '19 at 05:27
  • @HansPassant it works. thanks `[Dirs]` `Name: "{commonappdata}\MyApp" ; Permissions: users-modify users-full` – samgi May 07 '19 at 05:54
  • 1
    See also [Privileges/owner issue when writing in C:\ProgramData](https://stackoverflow.com/q/22107812/850848). – Martin Prikryl May 07 '19 at 06:37

0 Answers0