PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Peek cannot peek on mapped network drive if PowerToys is running as admin

Open The-MAZZTer opened this issue 2 years ago • 7 comments
trafficstars

Microsoft PowerToys version

0.70.0

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

Peek

Steps to reproduce

  1. Map a network drive to a share in an unelevated process.
  2. Launch an elevated app (such as cmd or pwsh) and check that the drive is indeed not available when elevated.
  3. Open File Explorer unelevated.
  4. Navigate to the network drive letter.
  5. Peek any file or folder on it.

✔️ Expected Behavior

Peek works as expected.

❌ Actual Behavior

Because the drive is only mapped for unelevated processes, Peek fails to read the file and you get an error message.0

Not sure what a good fix for this is. Given there is also an issue with Mouse Without Borders regarding elevation, a long term solution may be to split PowerToys into two processes, one of which runs code that benefits from elevation, the other which runs the bulk of the code.

Another user reported they could not Peek files inside ZIP files (this is because Peek uses normal file system APIs to read files, so it can't Peek shell objects that don't have real files backing them). So it may make sense to use the shell API to read the files, I am not sure if that would help for this case or not.

Other Software

No response

The-MAZZTer avatar May 24 '23 04:05 The-MAZZTer

@SamChaps Looks like we have to start the module always non-elevated like we did for PT Run.

htcfreek avatar May 24 '23 05:05 htcfreek

I wonder if we should restrict Peek from running as admin. Is running File Explorer Windows as admin a thing?

Also, according to ChatGPT, right now we're hitting all of these with Peek: image

There might be an interest in keeping Peek available for admin or system windows.

jaimecbernardo avatar May 24 '23 13:05 jaimecbernardo

Is running File Explorer Windows as admin a thing?

@jaimecbernardo This is impossible. The Windows Explorer runs always in the user's context.

htcfreek avatar May 24 '23 16:05 htcfreek

I think a solution here might be to have a Setting that makes it so that Peek always runs un-elevated. And set that to true by default. That way people can disable that if they run into trouble.

jaimecbernardo avatar May 25 '23 10:05 jaimecbernardo

Can replicate this by creating a local network share like this:

net use t: \\localhost\c$\tempshare

When running as admin, Peek won't be able to view these files.

jaimecbernardo avatar May 25 '23 12:05 jaimecbernardo

Similar problem occurs if PowerToys is running under a different user after an update (my admin is separate) so accessing files in the personal folder fails as well (though I would have assumed that admins can read everything as they are, well, admins with elevated rights)

binarynoise avatar May 25 '23 13:05 binarynoise

@binarynoise , I think the fix I'm proposing should fix you case as well.

jaimecbernardo avatar May 25 '23 15:05 jaimecbernardo

Fixed in 0.71 release of PowerToys. aka.ms/installpowertoys

crutkas avatar Jul 14 '23 17:07 crutkas