EnvGet PATH output missing new variables? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Killaz
Posts: 11
Joined: 23 Aug 2016, 16:59

EnvGet PATH output missing new variables?

09 Apr 2019, 09:05

Hello! I am really frustrated by this problem. First of all, I'm using Windows 10.

This is my PATH environment variable
Image Broken Link for safety


When I run this code in Autohotkey, it does not show the phantomjs among other directories...

Code: Select all

EnvGet, test, Path
MsgBox % test

; this fails
Run, %comspec% /k phantomjs
It returns:
Spoiler

What is wrong?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: EnvGet PATH output missing new variables?

09 Apr 2019, 09:09

You could try adding this line before Run, in case there are separate 64-bit/32-bit versions of the PATH variable.

Code: Select all

DllCall("kernel32\Wow64DisableWow64FsRedirection", "Ptr*",0)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Killaz
Posts: 11
Joined: 23 Aug 2016, 16:59

Re: EnvGet PATH output missing new variables?

09 Apr 2019, 09:24

Thanks for the fast response but it didn't work. Same problem...

Code: Select all

'phantomjs' is not recognized as an internal or external command,
operable program or batch file.
It works when I run the CMD myself and type phantomjs but Autohotkey's comspec doesn't recognize it for some reason...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: EnvGet PATH output missing new variables?  Topic is solved

09 Apr 2019, 09:30

You could experiment with EnvSet:
EnvSet - Syntax & Usage | AutoHotkey
https://www.autohotkey.com/docs/commands/EnvSet.htm
I would backup the contents of any variables you modify to a text file.

When was PATH updated? In case maybe restarting the PC would fix it.
Perhaps AHK is somehow looking at an old version of the variable.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Killaz
Posts: 11
Joined: 23 Aug 2016, 16:59

Re: EnvGet PATH output missing new variables?

09 Apr 2019, 09:55

EnvSet solved the problem for me, thanks.
iseahound
Posts: 1445
Joined: 13 Aug 2016, 21:04
Contact:

Re: EnvGet PATH output missing new variables?

09 Apr 2019, 11:15

Yes you need to refresh AutoHotkey's environment, specifically:

Code: Select all

RefreshEnvironment()
{
   Path := ""
   PathExt := ""
   RegKeys := "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment,HKCU\Environment"
   Loop, Parse, RegKeys, CSV
   {
      Loop, Reg, %A_LoopField%, V
      {
         RegRead, Value
         If (A_LoopRegType == "REG_EXPAND_SZ" && !ExpandEnvironmentStrings(Value))
            Continue
         If (A_LoopRegName = "PATH")
            Path .= Value . ";"
         Else If (A_LoopRegName = "PATHEXT")
            PathExt .= Value . ";"
         Else
            EnvSet, %A_LoopRegName%, %Value%
      }
   }
   EnvSet, PATH, %Path%
   EnvSet, PATHEXT, %PathExt%
}
https://github.com/iseahound/Environment.ahk

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Spawnova and 310 guests