RFF: elevate single procedure
Posted: 2021 Mar 11, 04:12
Hi, Nikos - here comes that RFF.
So, what I envision is that, when, say, trying to delete a protected file or folder that requires elevated privileges, instead of having to run Xplorer² as admin to do so, is there any possibility of getting just a part of the code to elevate for a single procedure?
So, here is the rationale.
I still keep Windows Explorer around because every once in a while, there are files and folders that I can delete with a simple UAC prompt asking for elevated privileges that I cannot do so in Xplorer² - unless I allow it to elevate the entire program, and then have to select the items and do the whole procedure again. It actually takes me less time to "Open Explorer here" and then perform the deletion in Explorer than it does to allow X² to run as admin, select and perform the operation, and then close the new X² instance (not a lot longer, - say maybe a second or two) - but I've been using the workaround through Windows Explorer now for so long that it's rote.
What I'd prefer would be to have X² elevate the delete command only, or else revert to using the native file operations in Windows, which would then include the native UAC prompt for elevated privileges, without having to run a new elevated instance of X² completely. If I could get rid of this one problematic feature of Windows and its protected files like this, then I could use X² as my default FM including replacing with [WinKey] + [E] shortcut. As it is, I still have to keep Windows Explorer on standby for this specific procedure.
So, now that I've written all that down, I suppose the original idea was for a subroutine to get (temporary) elevated privileges to perform that one duty and then revert to regular privileges, but I guessed that you'd say "X² doesn't work that way - to do one thing with elevated privileges you need to elevate the program." So it then sort of morphed into a slightly different RFF, if a file operation is going to require elevated privileges, to drop to using native OS operation calls so that the OS can directly pass elevated privileges for the one operation. if that is even possible?
If you cannot, cool. Just thought I'd ask.
So, what I envision is that, when, say, trying to delete a protected file or folder that requires elevated privileges, instead of having to run Xplorer² as admin to do so, is there any possibility of getting just a part of the code to elevate for a single procedure?
So, here is the rationale.
I still keep Windows Explorer around because every once in a while, there are files and folders that I can delete with a simple UAC prompt asking for elevated privileges that I cannot do so in Xplorer² - unless I allow it to elevate the entire program, and then have to select the items and do the whole procedure again. It actually takes me less time to "Open Explorer here" and then perform the deletion in Explorer than it does to allow X² to run as admin, select and perform the operation, and then close the new X² instance (not a lot longer, - say maybe a second or two) - but I've been using the workaround through Windows Explorer now for so long that it's rote.
What I'd prefer would be to have X² elevate the delete command only, or else revert to using the native file operations in Windows, which would then include the native UAC prompt for elevated privileges, without having to run a new elevated instance of X² completely. If I could get rid of this one problematic feature of Windows and its protected files like this, then I could use X² as my default FM including replacing with [WinKey] + [E] shortcut. As it is, I still have to keep Windows Explorer on standby for this specific procedure.
So, now that I've written all that down, I suppose the original idea was for a subroutine to get (temporary) elevated privileges to perform that one duty and then revert to regular privileges, but I guessed that you'd say "X² doesn't work that way - to do one thing with elevated privileges you need to elevate the program." So it then sort of morphed into a slightly different RFF, if a file operation is going to require elevated privileges, to drop to using native OS operation calls so that the OS can directly pass elevated privileges for the one operation. if that is even possible?
If you cannot, cool. Just thought I'd ask.