OSDN Git Service

installer: find the correct program files path in the registry. Correctly check...
authorMichael Curran <mick@kulgan.net>
Mon, 2 Apr 2012 09:40:28 +0000 (19:40 +1000)
committerMichael Curran <mick@kulgan.net>
Mon, 2 Apr 2012 09:40:28 +0000 (19:40 +1000)
source/installer.py

index 338f134..0c457e0 100644 (file)
@@ -23,7 +23,9 @@ def _getWSH():
        return _wsh\r
 \r
 defaultStartMenuFolder=versionInfo.name\r
-defaultInstallPath=os.path.join(unicode(os.getenv("ProgramFiles")), versionInfo.name)\r
+with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion") as k: \r
+       programFilesPath=_winreg.QueryValueEx(k, "ProgramFilesDir")[0] \r
+defaultInstallPath=os.path.join(programFilesPath, versionInfo.name)\r
 \r
 def createShortcut(path,targetPath=None,arguments=None,iconLocation=None,workingDirectory=None,hotkey=None,prependSpecialFolder=None):\r
        wsh=_getWSH()\r
@@ -157,8 +159,8 @@ def registerInstallation(installDir,startMenuFolder,shouldCreateDesktopShortcut,
        NVDAExe=os.path.join(installDir,u"nvda.exe")\r
        slaveExe=os.path.join(installDir,u"nvda_slave.exe")\r
        if shouldCreateDesktopShortcut:\r
-               createShortcut(u"nvda.lnk",targetPath=slaveExe,arguments="launchNVDA -r",iconLocation=NVDAExe+",0",hotkey="CTRL+ALT+N",workingDirectory=installDir,prependSpecialFolder="AllUsersDesktop")\r
-       createShortcut(os.path.join(startMenuFolder,"NVDA.lnk"),targetPath=NVDAExe,iconLocation=NVDAExe+",0",workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms")\r
+               createShortcut(u"NVDA.lnk",targetPath=slaveExe,arguments="launchNVDA -r",hotkey="CTRL+ALT+N",workingDirectory=installDir,prependSpecialFolder="AllUsersDesktop")\r
+       createShortcut(os.path.join(startMenuFolder,"NVDA.lnk"),targetPath=NVDAExe,workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms")\r
        createShortcut(os.path.join(startMenuFolder,_("NVDA Website")+".lnk"),targetPath=versionInfo.url,prependSpecialFolder="AllUsersPrograms")\r
        createShortcut(os.path.join(startMenuFolder,_("Uninstall NVDA")+".lnk"),targetPath=os.path.join(installDir,"uninstall.exe"),workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms")\r
        createShortcut(os.path.join(startMenuFolder,_("Explore NVDA user configuration directory")+".lnk"),targetPath=slaveExe,arguments="exploreUserconfigPath",workingDirectory=installDir,prependSpecialFolder="AllUsersPrograms")\r
@@ -182,10 +184,10 @@ def unregisterInstallation(forUpdate=False):
        except:\r
                pass\r
        wsh=_getWSH()\r
-       desktopPath=wsh.SpecialFolders("AllUsersDesktop")\r
+       desktopPath=os.path.join(wsh.SpecialFolders("AllUsersDesktop"),"NVDA.lnk")\r
        if os.path.isfile(desktopPath):\r
                try:\r
-                       os.remove(os.path.join(desktopPath,"nvda.lnk"))\r
+                       os.remove(desktopPath)\r
                except WindowsError:\r
                        pass\r
        startMenuFolder=getStartMenuFolder()\r