def installToStartMenu(self, shortcut, deleteOnClose = True): shortcut = Platform.toUnicode(shortcut) dstFile = os.path.join(self.windowsProgramsDir, os.path.basename(shortcut)) if os.path.exists(dstFile): os.remove(dstFile) try: win32file.CopyFile(shortcut, dstFile, True) if deleteOnClose: Platform.deleteOnclose(dstFile) except pywintypes.error, err: if err[0] == 5: # Access is denied print "Session::Windows::install_shortcut Access is denied on copy of '%s' to '%s'"%(shortcut, dstFile) else: # other error print "Session::Windows::install_shortcut error on copy of '%s' to '%s', wintypes error %s"%(shortcut, dstFile, err[0])
def installToDesktop(self, shortcut): shortcut = Platform.toUnicode(shortcut) if not os.path.exists(self.windowsDesktopDir): os.makedirs(self.windowsDesktopDir) dstFile = os.path.join(self.windowsDesktopDir, os.path.basename(shortcut)) if os.path.exists(dstFile): os.remove(dstFile) try: win32file.CopyFile(shortcut, dstFile, True) Platform.deleteOnclose(dstFile) except pywintypes.error, err: if err[0] == 5: # Access is denied print "Session::Windows::install_shortcut Access is denied on copy of '%s' to '%s'"%(shortcut, dstFile) return # other error print "Session::Windows::install_shortcut error on copy of '%s' to '%s', wintypes error %s"%(shortcut, dstFile, err[0]) return