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

Things you’d like to miss in the future...
hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

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

Post 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?

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

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

Post 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.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

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

Post by hyzhangzhy »

Thanks. I see.

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

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

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

Post by jupe »

This command could possibly help in your situation:

View | Caches | Refresh Environment Variables

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

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

Post 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....

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

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

Post 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
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

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

Post 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.

klownboy
Posts: 4140
Joined: 28 Feb 2012 19:27

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

Post 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%;
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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.
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

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

Post 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.

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

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

Post 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...

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

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

Post 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 2508 times

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

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

Post by admin »

:oops: Of course... :whistle:

Post Reply