summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tools/finish.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/finish.nim b/tools/finish.nim
index cdbbdabe5..a6f689eac 100644
--- a/tools/finish.nim
+++ b/tools/finish.nim
@@ -92,7 +92,13 @@ when defined(windows):
       echo "Could not access 'config/nim.cfg' [Error]"
 
   proc addToPathEnv*(e: string) =
-    let p = getUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER)
+    var p: string
+    try:
+      p = getUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER)
+    except OSError:
+      p = getUnicodeValue(
+        r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
+        "Path", HKEY_LOCAL_MACHINE)
     let x = if e.contains(Whitespace): "\"" & e & "\"" else: e
     setUnicodeValue(r"Environment", "Path", p & ";" & x, HKEY_CURRENT_USER)