Powertoys: Power Rename - Endless Explorer.exe crash loop when renaming User Directory

Created on 28 Mar 2020  路  18Comments  路  Source: microsoft/PowerToys

Environment

**Windows build number:** Microsoft Windows [Version 10.0.18363.720]
**PowerToys version:** Version v0.15.2
PowerToy module for which you are reporting the bug (if applicable): Power-Rename

Steps to reproduce

  1. go to C:/Users
  2. Rightclick user profile folder.
  3. Power Rename.

Expected behavior

Either a rename, if I am allowed, OR, a message to say that I'm unable.

Note that explorer.exe hides the rename option, which is why I tried to power rename it.

Actual behavior

Explorer.exe will hang for a short time, but then will get into a crash-kill-boot loop and the computer has to have a hard restart.

Screenshots

Can't be bothered to do it again but you should be able to understand what a crashing explorer looks like. :)

Issue-Bug Needs-Author-Feedback Needs-Repro Product-PowerRename Resolution-Fix-Committed

All 18 comments

Can you even rename the DIR with explorer? Think this will be a larger don鈥檛 rename important folders.

I had to rename it due to an issue building my own projects (using my full name as user account brings in a space on the folder, what a pain)

I ended up solving it by making a different account, switching, renaming, change reg, then switching back.

Works fine, but I was hoping to do it without making the account, so I tried power rename. Explorer option wasn't there.

It's fine for power to not allow me, but it shouldn't cause a hard reset.

I don't mind if this gets a WONTFIX I just thought you guys might be interested

To verify, you renamed the "User" directory or a user inside the directory?

renamed the user home directory, from inside C:\Users\

So for instance c:\users\foo to \bar?

Was the user the same being logged in?

Just trying to be sure we simulate it correctly.

yes foo to bar as logged in as foo.
Explorer by default hides it, powershell should alert at the very least. not sure how it applies to "renaming admin without admin privileges" either.

Yeah, we need to add in some safety rails here. Great catch

Note that explorer.exe hides the rename option, which is why I tried to power rename it.

There is a very good reason that Explorer does not show a rename option for a User folder. Because a lot of programs and registry settings use this folder, and renaming is messed up a lot. General advice = do not mess with these folders. You can "soft-rename" it in some settings (imma have to get back on you for the specifics on that), but don't mess with the actual folder name.

If the name of the folder seems to be a problem, the best/safest thing you can do is create a new local account, so you can type the username that will become name of the new folder. After that, you can change the displayed username or log in with an Outlook account, if you would want to.

Having that said - are we sure this is a PowerToys related issue? Isn't it just Windows or Explorer who is unable to acces files in the user's profile folder, because it changed name?

Crutkas: edited a word

It is PT enabling a no-no scenario. We need to be defensive against that.

PowerRename should check each item passed to it has SFGAO_CANRENAME capability. We should check the passed payload for at least one item that has SFGAO_CANRENAME enabled (see IShellItem::GetAttributes) before even showing the context menu item. Also, this should be checked in the code logic as well, not just in the QueryContextMenu call. I'm curious about the crash in Explorer. I'll try this out on a VM when I get a chance.

This isn't just the User profile folder. Other "special" folders are protected in the same way - like the Windows folder.

I just tried to repro this and the rename hits an error right away. No change to the user profile folder. No crash in explorer.

image

Close as can't repro then

@muratakburak can you provide a clear repro? Chris just tried and it worked as expected.

It doesn't actually perform so smoothly on my machine as Chris's.
When I try to rename user folder, PowerRename freezes and doesn't respond but if I just go into the user folder, select all files in it without including parent user folder and try to rename a random file, it behaves in the same way. I guess its just because there are too many files in it(~166k).
I probably misperceived the reason of the freeze earlier thinking it is because of user folder.
Can't repro either.

It doesn't actually perform so smoothly in my machine as Chris's.
When I try to rename user folder, PowerRename freezes and doesn't respond but if I just go into the user folder, select all files in it without including parent user folder and try to rename a random file, it behaves in the same way. I guess its just because there are too many files in it(~166k).
I probably misperceived the reason of the freeze earlier thinking it is because of user folder.
Can't repro either.

I noticed the perf issue as well. CPU profiling showed the slowdown due to advancing through all the items in the std:map and updating the list view. This is due to a limitation in how the items are stored. They are not stored in how they are laid out on the file system. I'll have to investigate if we can mitigate this easily or if it requires substantial refactoring of code and data structures.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.

We just released 0.20 and this should be resolved there. Please try it out.

Was this page helpful?
0 / 5 - 0 ratings