Run as administrator option opens in background without focus

Found a bug in "Everything"? report it here
Post Reply
greatwroth
Posts: 4
Joined: Thu Dec 14, 2017 2:19 am

Run as administrator option opens in background without focus

Post by greatwroth »

Using the "Run as administrator" option in Everything causes the program to open behind other windows and shifts focus to the topmost window. Running as admin from either context menu or compatibility fixes this.
Everything v1.4.1.887 (x64)
Windows 10 Pro x64 Fall Creators build (1709)
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Run as administrator option opens in background without focus

Post by NotNull »

Try changing the properties of the shortcut you use to start Everything:
Shortcut tab > Advanced button > Enable Run as administrator.

But ...
Running Everything as Administrator will cause all files/programs that are started from Everything also to be started as Administrator,
Using the Administrator account is one way to access the parts of the Windows filesystem (called MFT and USN journal) that makes Everything amazingly fast (limited users can't access that)
Another way would be to disable the "Run as Administrator" and enable "Everything Service" (both can be found under Menu:Tools > Options > General).
That way Everything (running under your limited account) 'talks' to the Everything service and this service has the rights to read the MFT and USN


BTW: Don't you get a UAC prompt? ("Do you allow that this app changes your system?" or something similar)?
greatwroth
Posts: 4
Joined: Thu Dec 14, 2017 2:19 am

Re: Run as administrator option opens in background without focus

Post by greatwroth »

Any method to run as admin other than the option in Everything results in Everything opening on top with focus as desired and I've since been using the compatibility setting. I have UAC prompting disabled for my own reasons (yes I do know the risk) and when enabled Everything does open as desired.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Run as administrator option opens in background without focus

Post by NotNull »

If I understand correctly, your account is already an administrator (otherwise there would be no risk). If you disabled UAC, there is no longer a need to use the Run as admin setting!


Little background (somewhat simplified):
If you log in, Windows gives you a security badge (it's called a token) with on that your permissions /group memberships etc.
You use that badge whenever you want to access to something.

What UAC does, is creating a separate badge when you are an administrator. This token has the same permissions as your original one, minus the permissions that can ' seriously harm' the system. That's the token you get and use when you log in.

You are allowed to use the extra ('harmful') permissions that are on your other token, but only after UAC confirmation (the UAC prompt).
After this confirmation, UAC gives you the full power token, which you then use.

If you disabled UAC, there is no restricted token. You do everything (no pun intended ; -) with your unrestricted token.


Long ttory short: You can disable the Run as admin setting and Everything will work exactly the same as with this setting enabled.
Little difference: Now it will most likely start in the foreground.
Last edited by NotNull on Thu Dec 14, 2017 7:00 pm, edited 1 time in total.
greatwroth
Posts: 4
Joined: Thu Dec 14, 2017 2:19 am

Re: Run as administrator option opens in background without focus

Post by greatwroth »

Not entirely accurate; I am the admin and only account on my PC but I did not completely disable UAC, only UAC prompting as you cannot completely disable UAC through User Account Control Settings like you can in Windows 7.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Run as administrator option opens in background without focus

Post by NotNull »

Ah, confusion ... I interpreted "UAC prompting disabled"as "UAC disabled" ...

You know you can still disable UAC on Win10? (although not through the UAC settings dialog like you already mentioned)
greatwroth
Posts: 4
Joined: Thu Dec 14, 2017 2:19 am

Re: Run as administrator option opens in background without focus

Post by greatwroth »

Yes and though I would not suggest this to most it would also solve the issue.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Run as administrator option opens in background without focus

Post by NotNull »

greatwroth wrote:Yes and though I would not suggest this to most ...
I thought about posting how to do it, but eventually thought it would be better not to, because of that.

BTW: I wouldn't even suggest running as an administrator to most. Even with UAC enabled. There are about 30 ways (and counting) to bypass UAC, without being aware.

BTW2: About a year ago I did a deep-dive into UAC. I remember vaguely something about handles to application windows. They should be ' handled' (ahem..) in a special way with UAC, So it might as well be something in the code of Everything. But I mght be completely wrong about that (I'm not a programmer) Just trying to help.
void
Developer
Posts: 16680
Joined: Fri Oct 16, 2009 11:31 pm

Re: Run as administrator option opens in background without focus

Post by void »

Running as admin from either context menu or compatibility fixes this.
When you run Everything with the "Run as administrator" option enabled, Everything will launch as a standard user and start another Everything.exe process as administrator.
The standard user Everything.exe process will sit around wait for the admin Everything.exe process to exit, allowing you to use wait handles on the standard user Everything.exe process.

For some reason the new Everything process running as administrator is not receiving the foreground, even through the original standard user Everything.exe specifically sets AllowSetForegroundWindow to allow this.
It's possible the original standard user Everything.exe does not receive the foreground either.

Added to my experimental TODO list: make the user-run Everything create a zero width and zero height window that has the foreground and pass that foreground to the admin Everything. -This has worked well for other instances where we lose focus
Post Reply