notepad2-mod icon indicating copy to clipboard operation
notepad2-mod copied to clipboard

Allows to try administrator mode in case of UAC control

Open xupefei opened this issue 10 years ago • 5 comments

Hi, I have made a little improvement to allow Notepad2 run in administrator mode to bypass the UAC control (which makes the file read-only).

First, Notepad2 will try to create a temp file (named like "F9168C5E-CEB2-4FAA-B6BF-329BF39FA1E4") in the target folder. If this is not successful, it will ask for UAC permissions and try again. If it fails again, Notepad2 still opens it, but as read-only.

PS: The rpcrt4.lib required below is for UUID generating.

Hope you like it :)

xupefei avatar Apr 20 '14 19:04 xupefei

@xupefei: sorry for the so late answer.

Do you actually use this patch in real life? Does it work OK for you?

XhmikosR avatar May 01 '16 06:05 XhmikosR

Notepad2 will try to create a temp file (named like "F9168C5E-CEB2-4FAA-B6BF-329BF39FA1E4") in the target folder. If this is not successful, it will ask for UAC permissions and try again.

This is non sense. Trying to create a new file is in Noway a good check to see if I can write to another one in the same folder, regardless of UAC or not. I might be able to create a new file but I still might not have permissions to save the original one. Not only I might not have permission to create new files but can edit existing ones. If you don't want to ask the OS for the permissions chains the attempt must be done on the file I'm touching not on another one.

mauroservienti avatar May 01 '16 08:05 mauroservienti

In real Windows OS the ACL policy is usually applied on dictionaries, not on single file, so test the write permission on the dictionary is (in most cases) also effective for that file. I agree with you that it is better to perform testing on original file, but in that case we need to deal with file timestamp and (possibly) filesystem notification which is monitoring that file. In contrast, if we create a new file, we will not touch the original one and filesystem listener will not be notified.

xupefei avatar May 01 '16 09:05 xupefei

But the solution in this PR still have one problem: It will still ask for UAC if user is opening a file from a read-only device, e.g. CDROM.

xupefei avatar May 01 '16 09:05 xupefei

In real Windows OS the ACL policy is usually applied on dictionaries, not on single file, so test the write permission on the dictionary is (in most cases) also effective for that file.

Yeah, agree. The fact is that, IMHO, usually and in most cases are not a solution but a workaround. That's it.

mauroservienti avatar May 01 '16 09:05 mauroservienti