diff --git a/ring.nsi b/ring.nsi
index 458d8b24645c62c51f5c85cea6cd5e531caa0322..97e3f4eaff941b19f36c6eaab81a01b8fa3923a8 100644
--- a/ring.nsi
+++ b/ring.nsi
@@ -46,6 +46,51 @@ outFile "ring-windows-nightly.exe"
 !include LogicLib.nsh
 !include "FileFunc.nsh"
 
+Function StrRep
+  Exch $R4 ; $R4 = Replacement String
+  Exch
+  Exch $R3 ; $R3 = String to replace (needle)
+  Exch 2
+  Exch $R1 ; $R1 = String to do replacement in (haystack)
+  Push $R2 ; Replaced haystack
+  Push $R5 ; Len (needle)
+  Push $R6 ; len (haystack)
+  Push $R7 ; Scratch reg
+  StrCpy $R2 ""
+  StrLen $R5 $R3
+  StrLen $R6 $R1
+loop:
+  StrCpy $R7 $R1 $R5
+  StrCmp $R7 $R3 found
+  StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
+  StrCpy $R2 "$R2$R7"
+  StrCpy $R1 $R1 $R6 1
+  StrCmp $R1 "" done loop
+found:
+  StrCpy $R2 "$R2$R4"
+  StrCpy $R1 $R1 $R6 $R5
+  StrCmp $R1 "" done loop
+done:
+  StrCpy $R3 $R2
+  Pop $R7
+  Pop $R6
+  Pop $R5
+  Pop $R2
+  Pop $R1
+  Pop $R4
+  Exch $R3
+FunctionEnd
+
+!macro _StrReplaceConstructor ORIGINAL_STRING TO_REPLACE REPLACE_BY
+  Push "${ORIGINAL_STRING}"
+  Push "${TO_REPLACE}"
+  Push "${REPLACE_BY}"
+  Call StrRep
+  Pop $0
+!macroend
+
+!define StrReplace '!insertmacro "_StrReplaceConstructor"'
+
 !macro VerifyUserIsAdmin
 UserInfo::GetAccountType
 pop $0
@@ -61,12 +106,19 @@ ${EndIf}
 function .onInit
         setShellVarContext all
         !insertmacro VerifyUserIsAdmin
+        ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation"
+        StrCmp $0 "" notfound
+        ${StrReplace} $0 "$\"" ""
+        StrCpy $INSTDIR $0
+        Goto done
+notfound:
         StrCpy $INSTDIR "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}"
         ${If} ${ARCH} == "x64"
          ${If} ${RunningX64}
             StrCpy $INSTDIR "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}"
          ${EndIf}
         ${EndIf}
+done:
 functionEnd
 
 Function LaunchLink
@@ -116,7 +168,7 @@ section "install"
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" ${APPNAME}
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
-        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\""
+        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" $INSTDIR
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\ring.ico$\""
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""