The other app stores an XML file that my app allows you to make modifications to. It lives in the top level of that app’s Parent folder.
Is there any way to access that folder from my app? I would imagine that running my app as an administrator might give me permission, but is there a way I could ask permission (like a Mac app does, when it wants access to certain user folders) once, and Windows will remember that it’s allowed in the future?
If not, is there a way to force my app to run as administrator on launch, assuming that will allow me to do what I want?
Have you already tried and found it’s not possible, or just assuming it’s not?
As far as I know, Windows won’t ask for permissions to access restricted folders. The user has to add the permissions to the folder itself (what you’re referring to at the Mac side is a really different thing than folder permissions; it’s a privacy restriction, another layer than the file system one).
I don’t know a way to change the Windows permissions to a given folder by code. Even if it was possible, it’s a per-user setting, not per-application.
This isn’t about where my app stores the files. My app needs to manipulate a file made by another application, which stores it in its app parent folder. I have no control over that.
I have a mac at home and started work on my application this weekend there. It occurred to me that this might be a problem after I began putting the rest of the app together. So no, I haven’t tested it, but googling tells me that the folder is probably restricted. If my app has to be run as administrator, I guess that’s ok, but I’d prefer not to if I don’t have to.
Ok, thanks. I’ll have to play with this a bit. When I test it, is there a difference between a compiled app and running it from the debugger, when it comes to these kinds of things? Anything I’ve ever done in Xojo has only been about manipulating files that my own apps create, not something like this.
Is there any way to access that folder from my app?
Yes. Just navigate to that folder. It would honestly be easier and not out of the ordinary to ask the user where that application’s folder is.
Is there a way I could ask permission (like a Mac app does, when it wants access to certain user folders) once, and Windows will remember that it’s allowed in the future?
Sort of, but no the permission won’t be “remembered”. I won’t go into this technique because you’ll have to do it for each time the app is launched.
If not, is there a way to force my app to run as administrator on launch, assuming that will allow me to do what I want?
Yes, have the installer set the RUNASADMIN registry key.
Maybe it’s enough to set the Security Setting in the Advanced Area of the App Object Settings within Xojo, to Administrator? (Only avail. for 64bit Apps).
Quick update on this - nothing to see here, please move along…
Turns out there’s nothing stopping my app from reading/writing text in another app’s parent folder. I made a quick test app to read in, append to, and write back the default XML file that the scanner software installs. At least on Windows 10, which is what our scanner is running under, this works fine with no special permissions or anything - In my app I just assigned it User privileges, not Admin. I assume newer scanners ship with Win11, so this will need to be tested there as well, but for now, it seems to work just fine.