Page 1 of 2

CMD opened by XYplorer does not react to the changes of the system variable

Posted: 06 Feb 2018 08:17
by hyzhangzhy
It seems cmd windows opened by XYplorer (toolbar button or ctrl+alt+p), does not react to system variable change no matter how many times I restart the cmd window(still by XYplorer).

I must restart XYplorer to make the system variable change to work.

And when I start a cmd window from start menu, I do not have to restart explorer.exe to make the changes to work. is this a bug?

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 06 Feb 2018 08:22
by jupe
As a workaround that could work, if you are not already aware you can hold Shift+RClick a folder and select "Open Command Window here" from the shell context menu.

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 06 Feb 2018 08:31
by highend
It's not a bug. The cmd inherits the environment from XY. But that doesn't mean that the current behavior can't be improved.
XY could listen to the WM_SETTINGCHANGE broadcast message...

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 06 Feb 2018 08:45
by hyzhangzhy
Thanks. I see.

And it seems TC does not have this currently... 8)

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 12 Feb 2018 13:38
by jupe
This command could possibly help in your situation:

View | Caches | Refresh Environment Variables

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 12 Feb 2018 14:25
by highend

Code: Select all

View | Caches | Refresh Environment Variables
That's something I tried in the first place as well. But adding an environment variable and
then start a dos box from XY and use "set" in it doesn't reflect the OS environment update...

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 12 Feb 2018 14:39
by jupe
Sorry, I should have known you'd tried that already, in fact I should have tried before I suggested it, was just being lazy....

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 12 Feb 2018 16:30
by klownboy
You may be interested in a little more background information on using environmental variables in XYplorer. viewtopic.php?f=5&t=9082 There's also this thread that discusses having an "Environmental Refresh" that would actually reread the environment as XY does when started from scratch viewtopic.php?f=2&t=13377

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 20 Feb 2018 09:16
by admin
highend wrote:It's not a bug. The cmd inherits the environment from XY. But that doesn't mean that the current behavior can't be improved.
XY could listen to the WM_SETTINGCHANGE broadcast message...
I'll add that in next beta.

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 20 Feb 2018 16:26
by klownboy
Hi Don, if I run the following which creates an environmental variable MYVAR and sets it as [home] and then perform an environmental refresh (#505), XYplorer still doesn't see it until a restart. It's not listed in XY's Help | Environmental Variables either. I do see the status message come up, but XYplorer is not seeing the new environmental variable. The command does work since it is listed immediately in Windows under Control Panel | System | Advanced System settings | Environmental Variables. Of course there, it's listed under "user" environmental variables not "system" environmental variables.

Code: Select all

  run "cmd /c /q set MYVAR= & setx MYVAR [home]",,0,0;
  #505;
  echo %MYVAR%;

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 20 Feb 2018 16:38
by highend
Can confirm it here...
Doing a change inside Control Panel | System | Advanced System settings | Environmental Variables,
e.g. adding a new environment variable for the current user
will inform XY but it isn't able to accesss it / show it, etc.

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 20 Feb 2018 16:58
by admin
Same here. I just researched this and surprisingly this seems to be by design. Each process is protected against changes of these variables from the outside, so it can rely on the values as long as it lives:

See MS:
https://msdn.microsoft.com/de-de/librar ... s.85).aspx
And some discussion:
https://social.msdn.microsoft.com/Forum ... arpgeneral

The only workaround seems to be to read the registry directly. But that would undermine the design.

This could mean that I should remove "View | Caches | Refresh Environment Variables" since it's utterly useless.

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 22 Feb 2018 10:15
by admin
admin wrote:This could mean that I should remove "View | Caches | Refresh Environment Variables" since it's utterly useless.
So, I will remove that function since it does not work, and never did. If you have had other experiences speak up now...

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 01 Mar 2018 07:17
by jupe
Since you have now removed the function, will you be removing the listener for WM_SETTINGCHANGE just for for enviro variables?, because I keep getting this message and sometimes it overwrites a message I want to read from a script, I assume that it isn't needed anymore?

I think I see this message frequently because explorer keeps crashing on my rig, so when it reloads it must send out the broadcast, but I don't see the message instantly, it pops up a little while later, anyway I assume that is the cause because I am not changing them myself.
enviro-refresh.png
enviro-refresh.png (2.01 KiB) Viewed 3364 times

Re: CMD opened by XYplorer does not react to the changes of the system variable

Posted: 01 Mar 2018 08:42
by admin
:oops: Of course... :whistle: