From 68573630340f60f452d5f206da37017e47bd8f6e Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 17 May 2017 21:48:36 +0200 Subject: [PATCH] finish.nim tool: use global path environment variable if local does not exist --- tools/finish.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)