26

Is there any way to disable the CTRL+Z (Undo) shortcut in Windows Explorer? Alternatively, is there a way to have Windows Explorer "forget" its undo history?

The reason I ask is that you may have done some file operations in Explorer (copying, renaming, etc.), and perhaps you don't reboot for days or longer (choosing to hibernate instead). The problem is that if you accidentally hit CTRL+Z one or more times (often mistaking which application you have in the foreground; using a dual-monitor setup will increase that likelihood), you may be undoing something that was done ages ago without realizing what happened.

Even if you do realize what has happened, you may not remember what the last several operations were that you did potentially days ago. As far as I can tell, there is no "Redo" function in Windows Explorer to save you. I can imagine scenarios in which this mistake could cause lots of problems.

If the shortcut can be disabled, it would at least force you to use the Edit > Undo menu item before doing something stupid. Otherwise if the undo history could be periodically cleared, that would prevent some very old operations from being undone.

Addendum: For those interested in implementing this, I created an AHK file that runs silently (the #NoTrayIcon option) from my Windows Startup folder. Besides some other useful shortcuts I incorporated, this is what it looks like:

#NoTrayIcon
SetTitleMatchMode RegEx
return

; Disable Ctrl+Z shortcut in Windows Explorer
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass
^z::return
#IfWinActive

If you prefer feedback instead of CTRL+Z simply doing nothing, play a default sound or use MsgBox to cause a dialog to appear.

#IfWinActive ahk_class ExploreWClass|CabinetWClass
^z::
    ;Uncomment the feedback option you prefer below
    ;SoundPlay *-1
    ;MsgBox Ctrl+Z has been disabled.
return
#IfWinActive
3
  • There is redo and its shortcut is Ctrl+Y by the way.
    – Taylan
    Commented Jan 31, 2018 at 6:44
  • 3
    @Taylan The redo doesn't recover files that were in new folders that you "undid" the creation of. Neither are they in recycle bin. Extremely dangerous Commented May 22, 2019 at 12:45
  • I did not even know this was a thing, but I immediately disabled it.
    – Jan Doggen
    Commented Jan 3, 2023 at 14:05

6 Answers 6

15

I wrote a program in C to disable both the Undo and Redo shortcuts, since both can lead to accidents.

The program can be found at http://purl.org/net/dweundo .

It has an installer which, if you want, adds a shortcut in the Start Menu 'Startup' folder, so the program starts when you log on.

2
  • Just tried it out, works great so far! I like this solution much better. Commented Dec 4, 2013 at 23:07
  • Thank you! Works in all cases I've tried, and very low memory footprint. Commented Oct 1, 2016 at 15:45
7

I think you can have Autohotkey override an existing shortcut.

^z::
return

Will make Ctrl + z do nothing

Edit: This will apply everywhere. To apply in explorer only, try this:

#IfWinActive ahk_class ExploreWClass
^z::
#IfWinActive ahk_class CabinetWClass
^z::
return
#IfWinActive
1
  • Thanks, this is a great little utility! I've edited your answer to include also the ExploreWClass as Explorer can run as either depending on how it is launched. The trailing #IfWinActive should be used so the hotkey doesn't fall through to any commands in the script beneath it. Commented Apr 8, 2011 at 15:44
3

11 years passed and, though redo has been added to explorer, there's still no prompt and mistakes still happen from time to time :(
But just now I found a recent article at https://www.winhelponline.com/blog/disable-undo-redo-feature-in-windows/ which proved to be a perfect solution (seems to be a new feature; not tested on older systems). The nice thing is that you don't have to install or run anything new, just add a zero DWORD value with name MaxUndoItems in registry HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced and enjoy. Just note that it disables undo & redo in explorer completely so you can't do that in context menu afterwards, either. After years I can finally get rid of this so-called "shortcut"!
(Well, it will be even nicer if undo & redo are still kept in the context menu or they can be assigned to other keys. But we shouldn't push Microsoft too hard XD)

1
  • 1
    Glad to see this as an option. While this does prevent use of Ctrl+Z, it also effectively disables Undo and Redo for Windows Explorer if set to 0, so just know that. You may mention that this is created as a DWORD value. Commented Oct 26, 2022 at 14:52
1

The given scripts seems works correctly except for objects (files, folders, etc) placed on the Desktop.
Suppose, in fact, you have a folder named MyFolder on your Desktop and you rename it to NewName. Accidentally pressing CTRL+Z will cause you to lose the change reverting to MyFolder.

I paste a new script release catching also Desktop:

#IfWinActive ahk_class ExploreWClass
^z::
#IfWinActive ahk_class CabinetWClass
^z::
return
#IfWinActive ahk_class Progman
^z::
return
#IfWinActive

Thank you for sharing this usefull autokey, unfortunately I lost a whole document due a stupid Windows feature/bug in correlation with accidental CTRL+Z shortcut :|.

1
  • The script seems not working correctly on Windows 8.1. I'll post a code upgrade.
    – Eddie C.
    Commented Dec 17, 2013 at 22:34
0

This AutoHotKey script catches Explorer windows, as in other answers, but also the Desktop:

#IfWinActive ahk_class CabinetWClass ; Explorer
^z::
#IfWinActive ahk_class ExploreWClass ; Explorer (legacy)
^z::
#IfWinActive ahk_class Progman ; Desktop
^z::
#IfWinActive ahk_class WorkerW ; Desktop shown by Win+D
^z::
    MsgBox Ctrl+Z has been disabled.
return
#IfWinActive


Still, I think the best solution is to use the program written by Jelle Geerts (see his anwser).

1
  • I agree that dweundo is the best. Me too I'm using that since discovered.
    – Eddie C.
    Commented Oct 4, 2016 at 11:25
0

2023 - Windows 11 22H2

I was seeing something like this:
windows 11 right click menu with "undo new" highlighted

To disable it (reg-add):

reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v MaxUndoItems /d 0 /t REG_DWORD

and then restart "Windows Explorer" using task manager

source

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .