Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request(environment variables): Update environment variables after Far Manager restart #31

Closed
Kristinita opened this issue Mar 5, 2018 · 8 comments
Assignees
Labels

Comments

@Kristinita
Copy link

Kristinita commented Mar 5, 2018

1. Summary

It would be nice, if Far Manager would update environment variables after restart as in native Windows console (cmd.exe).

At the time I need restart Windows, that get updated environment variables for new sessions.

Related question.

2. Steps to reproduce

I set any variable:

C:\Users\SashaChernykh>setx SASHAVAR 4147

SUCCESS: Specified value was saved.

I restart terminal → I print echo %SASHAVAR%.

3. Expected behavior

If terminal == native Windows console or Far Mode in ConsoleZ:

C:\Users\SashaChernykh>echo %SASHAVAR%
4147

4. Actual behavior

Elif terminal == Far Manager or Far Mode of ConEmu:

C:\Users\SashaChernykh>echo %SASHAVAR%
%SASHAVAR%

I prefer ConEmu, not ConsoleZ, but ConEmu, unfortunately, doesn't support automatic refresh environment variables in new session at the time.

5. Not helped

  1. see Not helped section for related question,

  2. F9OptionsAutomatic Update of environment variables:

    Automatic update

    Environment variables update for me without refresh in current session, but if I restart Far Manager, I get actual behavior, not expected.

  3. I can't find this feature in existing plugins as EnvMan.

6. Note

It would be nice, if would be possible update environment variables, if user run terminal in Far mode use different actions. For example, I run ConEmu in Far mode via:

Thanks.

@alabuzhev
Copy link
Contributor

It's quite hard to understand you, but I'll try.
It looks like you're "restarting" far from conemu without restarting conemu itself and since conemu does not update its environment auromatically - you get the outdated snapshot.
If so - sorry, but inheriting parent's environment is a fundamental concept and won't change.
If conemu's environment is outdated - it's its own problem, not ours. You have to restart it then (or, as has been suggested there, start far from explorer and attach to it).

@Kristinita
Copy link
Author

Kristinita commented Mar 5, 2018

@alabuzhev ,

OK, to simplify the problem, no ConEmu, no ConsoleZ, only Far.exe without any wrappers.

See 2—4 sections of issue.

If I use native Windows console:

    environment variables refresh after cmd.exe restart.

elif I use Far Manager:

    environment variables doesn't refresh after Far.exe restart.

Thanks.   

@Kristinita
Copy link
Author

You have to restart it then (or, as has been suggested there, start far from explorer and attach to it).

If you mean @BladeMight answer, it works for ConEmu in cmd.exe mode, but doesn't work for ConEmu in Far Manager mode.

Thanks.

@alabuzhev
Copy link
Contributor

I still don't understand you.
setx sets the variable in Registry and broadcasts WM_SETTINGCHANGE.
Windows Explorer processes that message and updates its environment. So does Far.

Try this:

  • set your variable using setx.
  • close Far.
  • press Win+R, type "c:\program files\far\far.exe" (or whatever your path is), press OK.
  • check your variable in that newly opened Far using echo. It should be there.

@Kristinita
Copy link
Author

If I run Far.exe via Win+RFar.exeEnter:

    environment variables successful update for me.

Else I run Far.exe via another method:

    for example, in Windows Explorer I move to folder %ProgramFiles%/Far Manager and double-click to Far.exe:

        environment variables doesn't update for me.

Is existing method, that update environment variables in second case?

Thanks.

@alabuzhev
Copy link
Contributor

alabuzhev commented Mar 6, 2018

I'll try to guess.
Do you have "Launch folder windows in a separate process" enabled in Control Panel - Folder Options - View - Advanced settings?
If yes - try to turn it off.
When explorer runs as two separate processes, for some reason it only updates the environment of the one of them, which is responsible for Start menu and Taskbar (and Win+R, as it's a part of Start Menu), but not the other one, which shows folders.

So, to summarise, to get an updated environment you can:

  • run Far from Win+R, Start menu or Taskbar
  • or turn off the option above
  • or just close all explorer windows and wait for about one minute - that additional process will exit and start again when you open a new window (you can also close it manually via Task Manager).

@Kristinita
Copy link
Author

run Far from Win+R, Start menu or Taskbar

or turn off the option above

or just close all explorer windows and wait for about one minute - that additional process will exit and start again when you open a new window (you can also close it manually via Task Manager).

Thanks! All 3 methods works for me.

But environment variables doesn't update, if I run Far Manager via Wox launcher or Sublime Text — 2 my preferred methods…

@alabuzhev
Copy link
Contributor

But environment variables doesn't update, if I run Far Manager via Wox launcher or Sublime Text — 2 my preferred methods…

Same as above: environment variables are inherited from the parent process, so if a program does not update its environment automatically - the only way is to restart it from some other program that does.
I.e. you need to close wox launcher and sublime text and start them again from explorer (using any of 3 methods above), or from far.

@alabuzhev alabuzhev self-assigned this Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants