diff --git a/mruclean.py b/mruclean.py index 0ac3e05..ec67da8 100755 --- a/mruclean.py +++ b/mruclean.py @@ -1,6 +1,6 @@ # Clean up selected MRU cruft from Win32 Registry # Copyright (c) 2002, TundraWare Inc., All Rights Reserved -# $Id: mruclean.py,v 1.3 2002/07/29 07:17:41 tundra Exp $ +# $Id: mruclean.py,v 1.4 2002/07/29 17:36:25 tundra Exp $ ############################################################ @@ -32,22 +32,76 @@ ############################################################ -mrulist = \ +##### +### These are keys at the lowest level of the registry that need +### cleaning. That is, these keys contain only values, no subkeys. +##### + +leafnodes = \ ( \ + r"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU", \ r"Software\Microsoft\Windows\CurrentVersion\Applets\Wordpad\Recent File List", \ r"Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List", \ r"Software\Microsoft\Office\9.0\PowerPoint\Recent File List", \ + r"Software\Microsoft\Office\9.0\Common\Open Find\Microsoft Excel\Settings\Save As\File Name MRU", \ r"Software\Microsoft\Office\9.0\Excel\Recent Files", \ r"Software\Microsoft\MediaPlayer\Player\RecentFileList", \ ) + +##### +### These are keys with subkeys that need cleaning. That is, +### each of the *subkeys* of each of these entries will be cleaned. +##### + +subkeys = \ + ( \ + r"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU", \ + ) + + +############################################################ +### Supporting Functions ### +############################################################ + + +##### +### Initialize a key back to its empty state. +##### + +def CleanKey(reg, key): + DeleteKey(reg, key) + CreateKey(reg, key) + + +############################################################ +### Main Program ### +############################################################ + + +### Connect to the local registry + reg = ConnectRegistry(None,HKEY_CURRENT_USER) -for entry in mrulist: - DeleteKey(reg, entry) - CreateKey(reg, entry) -### Special Cases +### Clean the leafnodes + +for entry in leafnodes: + CleanKey(reg, entry) + + +### Clean the subkeys + +for sk in subkeys: + k = OpenKey(reg, sk , 0, KEY_READ) + for i in range(0,1024): + try: + CleanKey(reg, sk + "\\" + EnumKey(k,i)) + except EnvironmentError: + break + CloseKey(k) + +### Clean the special cases k = OpenKey(reg, r"Software\Microsoft\Photo Editor\3.0\Microsoft Photo Editor", 0, KEY_WRITE) for x in range(1,1024):