uninstall.py

changeset 6510
d8fd663f86ef
parent 6509
884182bfd25c
child 6645
ad476851d7e0
equal deleted inserted replaced
6509:884182bfd25c 6510:d8fd663f86ef
217 217
218 def uninstallWindowsLinks(): 218 def uninstallWindowsLinks():
219 """ 219 """
220 Clean up the Desktop and Start Menu entries for Windows. 220 Clean up the Desktop and Start Menu entries for Windows.
221 """ 221 """
222 regPath = r"Software\Microsoft\Windows\CurrentVersion\Explorer" \ 222 try:
223 r"\User Shell Folders" 223 from pywintypes import com_error # __IGNORE_WARNING__
224 except ImportError:
225 # links were not created by install.py
226 return
227
228 regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \
229 "\\User Shell Folders"
230
224 # 1. cleanup desktop links 231 # 1. cleanup desktop links
225 regName = "Desktop" 232 regName = "Desktop"
226 desktopFolder = os.path.normpath( 233 desktopEntry = getWinregEntry(regName, regPath)
227 os.path.expandvars(getWinregEntry(regName, regPath))) 234 if desktopEntry:
228 for linkName in windowsDesktopNames(): 235 desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry))
229 linkPath = os.path.join(desktopFolder, linkName) 236 for linkName in windowsDesktopNames():
230 if os.path.exists(linkPath): 237 linkPath = os.path.join(desktopFolder, linkName)
231 os.remove(linkPath) 238 if os.path.exists(linkPath):
239 try:
240 os.remove(linkPath)
241 except EnvironmentError:
242 # maybe restrictions prohibited link removal
243 print("Could not remove '{0}'.".format(linkPath))
232 244
233 # 2. cleanup start menu entry 245 # 2. cleanup start menu entry
234 regName = "Programs" 246 regName = "Programs"
235 programsFolder = os.path.normpath( 247 programsEntry = getWinregEntry(regName, regPath)
236 os.path.expandvars(getWinregEntry(regName, regPath))) 248 if programsEntry:
237 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry()) 249 programsFolder = os.path.normpath(os.path.expandvars(programsEntry))
238 if os.path.exists(eric6EntryPath): 250 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry())
239 shutil.rmtree(eric6EntryPath) 251 if os.path.exists(eric6EntryPath):
252 try:
253 shutil.rmtree(eric6EntryPath)
254 except EnvironmentError:
255 # maybe restrictions prohibited link removal
256 print("Could not remove '{0}'.".format(eric6EntryPath))
240 257
241 258
242 def uninstallLinuxSpecifics(): 259 def uninstallLinuxSpecifics():
243 """ 260 """
244 Uninstall Linux specific files. 261 Uninstall Linux specific files.

eric ide

mercurial