Copy file over inuse file... User Account Control prompt

If I have an app running, that uses some dll files, and I attempt to copy over one of those in use files, I am prompted with the fullscreen 'User Account Control' > "Do you want to allow this app to make changes to your device?" (Directory Opus 13 (UAC Elevator).

I encounter this repeatedly when developing and updating files for that app, but having forgotten to exit the app first. I then have to cancel the UAC, exit the app, and then select the files to copy again.

As I understand UAC... this situation should not prompt the UAC requester because the files are not in a protected folder, for example "Program Files", but in a Documents subfolder. Instead it should prompt an ordinary copy error requester indicating it can't copy - with Retry/Cancel options. In this case I could quit the app and then just click Retry.

Is there a way to get this to happen? I can't find anything in the settings for it.

Unfortunately Windows returns the same error code (5, ERROR_ACCESS_DENIED) in both cases. There's no way to know definitively if the error was due to a permissions problem or something else.

I just tried doing this same copy with Windows File Explorer. Rather than getting a full screen UAC, I get this:

image

If I click continue, I get this:

image

At this point, if I quit the program using that file, I can click Try Again, and it works.

So, it seems like there are customizable implementations for how to deal with the Access Denied error.... that maybe could go directly to a requester handler.

Interestingly, I just asked Copilot this "how can I programmatically determine if a file is in use vs is protected by UAC" and it says...

In response to a File.Open call, a file in use gives and IOException while a UAC protected file gives UnauthorizedAccessException

I haven't tried it, but that may be a path to determining difference.

Explorer is white-listed by the OS under the default settings, and so is able to try elevation without actually showing a UAC prompt. If it wasn't white-listed the UAC prompt would appear between those two dialogs (that's what the shield icon indicates on the button on the first dialog).