finish.nim tool: use global path environment variable if local does not exist
This commit is contained in:
parent
b2e649c093
commit
6857363034
1 changed files with 7 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue