C++ app MDB in ProgramData copies to user's AppData folder when I dont want it to
Asked Answered
E

2

-1

I have a C++ program which connects to an Access database via OBDC System DSN connection. That DSN is a path to the MDB in the ProgramData folder. When User A runs the app, it copies that MDB file to their AppData\Local folder and any updates to the MDB the app makes, it does to the one in their AppData folder. This is no good because if User B runs the app I want them to see the changes that User A made to the MDB.

1) Is there a way to force it to NOT copy the MDB to their AppData folder and instead just use the one in ProgramData?

2) Am I doing this correctly? Should I be putting the MDB in a different location other than ProgramData where it will be properly shared?

3) Do I need to have my app on start up compare timestamps for the MDB? On start up I could have it pull from ProgramData and when it closes I could have it write back to ProgramData? This seems like a hack and I dont even know if permissions would be an issue

Emperor answered 9/4, 2017 at 14:28 Comment(2)
How do we know the answer to 1)? It's your application. Or isn't it? Can you modify it?Rael
The application isnt what is copying it. It is hitting the MDB via System DSN, and that System DSN points to the ProgramData location. Nothing in my app references the user's AppData folder... I assumed that is what ODBC was doing on the backend was copying it thereEmperor
H
0

Use (a subfolder of) the shared folder, %Public% which directs to C:\Users\Public.

Headforemost answered 9/4, 2017 at 15:42 Comment(6)
Thank you very much! Do you know if there is an Inno Setup constant for that? I dont see one in their documentationEmperor
Sorry, no, I know very little to Inno Setup. But I've added the tag for some expert to catch it.Headforemost
Should I be creating my folder with the MDB directly under C:\Users\Public? The reason I ask is I hardcoded that path in my Inno Setup installer and when it runs, it installs my folder under C:\Users\Public\Public Documents. Is that where it needs to go? Or should I focus on getting it under C:\Users\Public ?Emperor
That's up to you, but it appears that Inno Setup knows very well about the Public folder since - so it appears - it prefixes your path with the default path.Headforemost
I would prefer to keep it under the public drive... i.e. C:\Users\Public\MyApp. However when I put that path in Inno Setup it puts it at C:\Users\Public\Public Documents\MyApp. So maybe the install file doesnt have permissions to put it where I want so it moves it to under the Public Documents folder?Emperor
That seems to address the Documents folder. But as said, I'm no expert in Inno Setup.Headforemost
S
0

This post is relevant to OP's comment and previous answer by Gustav:

Use (a subfolder of) the shared folder, %Public% which directs to C:\Users\Public.

I am not an Inno setup expert either but I don't think a predefined constant for "C:\Users\Public" exists. But if its only a constant you want you can always do this.

Create a constant using #define macro at the very top of your script such as this.

#define sf "C:\Users\Public"

And you can use it in your script wherever you want. Ex:

[Files]
Source: "app.exe"; DestDir: "{#sf}\MyApp\";
Supersonic answered 10/4, 2017 at 12:38 Comment(4)
Yes I agree I dont believe there is a constant for it either. See my question below... Inno Setup is not putting it under C:\Users\Public... it is putting it under C:\Users\Public\Public DocumentsEmperor
@Emperor If you want to take this approach, you should better ask a more concrete question like "Resolving C:\Users\Public in Inno Setup".Rael
Will do. Thank you very much everyone!Emperor
Link: Inno Setup will not create folder under C:\Users\Public - will instead do C:\Users\Public\Public Documents.Rael

© 2022 - 2024 — McMap. All rights reserved.