[WFX] Environment Variables Ex

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Stefan2, white, sheep, Hacker

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

[WFX] Environment Variables Ex

Post by *speller2 » 2012-05-27, 10:41 UTC

http://www.totalcmd.net/plugring/envvars.html
Download link: http://www.totalcmd.net/download.php?id=envvars
FS-plugin for Total Commander. Intended for viewing and editing environment
variables of current process (TC), current user and system.

Made as a replacement for the Environment Variables plugin, but with following
differences:

- Fixed bug which makes editing impossible if a variable has a long value (such as PATH).
- Environment Variables Ex is entirely unicode and exists in x64.
- Added support of file operations on variables like on usual files: copy in and out of plugin, move, rename. Files putted into plugin can be in ANSI or Unicode encoding.
- Added custom columns support to show variables values in separate column without modifications.
- Added elevation dialog to change system variables.
Your comments and suggestions are welcome :)

Language files have the same format as in the original Environment Variables plugin, but in unicode encoding. The plugin ini file also have the same format, but in unicode encoding.

You can send your custom localization files by posting links here or mailing to me (speller@yandex.ru), and I will include them to the distribution.
Last edited by speller2 on 2012-05-31, 14:38 UTC, edited 2 times in total.

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Re: [WFX] Environment Variables Ex

Post by *sgp » 2012-05-27, 12:23 UTC

env vars ex beta tested on Win7 SP1 eng 32 bit

Thanks for this plugin! And here's my comments.

A leading dot in a variable name is replaced by an underscore character, i.e, .NAME becomes _NAME. If both .NAME and _NAME exist in the process environment it isn't possible to determine which is which. Try creating these two variables and then try changing them, you won't be able to change .NAME;

Code: Select all

.NAME=.name
_NAME=_name
I have an exiting process variable defined as (quotes ARE included)

Code: Select all

.ahk = "%@full[%@path[%ComSpec%]___/bin/ahk/AutoHotKey_exe]"
When I double click it in your plugin the value comes up empty.

Right-clicking a variable to select action Edit starts the editor associated with F4. This is inconsistent with TC which starts the system editor (notepad). If you want to keep F4 as the default, can you at least add a setting to envvars.ini so we can define our preferred editor to override the F4 editor?

What settings are available in settings.ini ? (The older plugin doesn't seem to document any settings, other than language).

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-27, 21:40 UTC

Yes, this is my mistake with dots, I will fix it soon. The goal of replacing dots by underscores was to disable line truncating by TC into the Name and Ext colums to make lines more readable. Also, the backslash is replaced by slash for such purpuse (old plugin did it too). All replacements made only for listing. I will check, maybe the content plugins API functionality will give a way to stop using this manipulations and to display values properly.

Now only language setting is available in the config.

The default TC editor is used because plugin just downloads a variable value to a local file. Editing of variables with F4 not implemented yet. At this moment, the only way to edit variable is to press Enter or double-click on it.

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-29, 13:32 UTC

http://www.totalcmd.net/download.php?id=envvars

Plugin is updated!

Fixed working with variables and its displaying: now in separate column, without modifications. Added support of basic file operations - you can manipulate variables in the same manner as usual files: copy, move files into and from the plugin, rename and delete them, edit by F4 as text file and upload back to the plugin to apply changes. Supported uploading of Unicode and ANSI text files.

Also, added the plugin settings dialog.

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp » 2012-05-29, 21:41 UTC

speller2 wrote:Plugin is updated!
Fixed working with variables and its displaying: now in separate column, without modifications.
Thanks for this update. I can confirm that the issues I reported are fixed.
Added support of basic file operations - copy, move files into and from the plugin, rename and delete them
Very cool and useful, being able to backup each variable in a single file, etc. It works mostly, however:
- copying variable name was _q_tmp out of the plugin and then back into it generated and upload error - I guess because a like-named variable already existed in the plugin?
- copying same variable out of the plugin, deleting the variable in the plugin and moving back the variable-file into the plugin still generated an upload error (maybe the plugin maintains "memory" of the previously existing, and now deleted, variable name?)
edit by F4 as text file and upload back to the plugin to apply changes.
Didn't work for me, I mean I could edit and save the value in the file, but the value in the plugin didn't change accordingly, even if I refreshed the list. Note: my F4 editor is a script that spawns the actual text editor, so the script exits while the editor is still running. Could this explain why F4 editing didn't work for me?

For completeness, it would be nice if your plugin supported volatile variables too, and a method to alert listening applications to update their environment variables (for user/system/volatile variables).

Thanks

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-29, 21:56 UTC

Thank you for report, will fix these issues soon.

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-30, 12:03 UTC

New update available: http://wincmd.ru/download.php?id=envvars
Fixed file operations bugs, tried to fix columns width misconfiguration (need to check).
but the value in the plugin didn't change accordingly, even if I refreshed the list. Note: my F4 editor is a script that spawns the actual text editor, so the script exits while the editor is still running. Could this explain why F4 editing didn't work for me?
I do not use my own editing handling. But use standard TC functions. First, TC downloads a file from plugin, runs an editor and waits for editor process exits. Then, after process exits, TC checks file modification and if file was changed it ask for file upload back to plugin. The only functions made by plugn: download file and upload file.
In your case, TC wait for script process exiting thinking this is an editor, end when your script exits before real editor, TC think file was not changed and do not suggest uploading back to plugin.
So, you should modify your script to wait until real editor process exit.

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-30, 12:10 UTC

For completeness, it would be nice if your plugin supported volatile variables too, and a method to alert listening applications to update their environment variables
I did not uderstand what you mean saying volatile variables? Can you explain?

The plugin already sends the broadcast message to all applications to update thier environments via standard message WM_SETTINGCHANGE after editing user or system variables.

ramses
Junior Member
Junior Member
Posts: 17
Joined: 2006-01-03, 13:59 UTC

Post by *ramses » 2012-05-31, 14:08 UTC

thank you for this plugin, i like it, its great !!!!!

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-05-31, 14:41 UTC

Thank you very much! :)

http://www.totalcmd.net/download.php?id=envvars

Also, I made the release! :) Changes from the last beta are:

- settings dialog box crash fixed.
- added the elevation dialog to apply changes of system variables.

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp » 2012-06-01, 08:15 UTC

speller2 wrote:Volatile variables? Can you explain?
http://www.tomshardware.co.uk/forum/29472-35-environment-variable-where wrote:Newly-started sessions take their variables from the following
registry keys, so that setting these before any sessions have started
will pass variables to the environment of these sessions:

HKLM\SYSTEM\CurrentControlSet\...\Environment
HKCU\Environment
HKCU\Volatile Environment

The HKEY_CURRENT_USER settings override (in the case of Path, append)
the values set in HKEY_LOCAL_SYSTEM. As the name suggests, the
Volatile Environment does not persist after restarting Windows.
speller2 wrote: The plugin already sends the broadcast message to all applications to update thier environments via standard message WM_SETTINGCHANGE after editing user or system variables.
Perfect.

Congrats on plugin release. Will test and report issues, if any. Thanks!

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp » 2012-06-01, 12:13 UTC

speller2 wrote:
but the value in the plugin didn't change accordingly, even if I refreshed the list. Note: my F4 editor is a script that spawns the actual text editor, so the script exits while the editor is still running. Could this explain why F4 editing didn't work for me?
I do not use my own editing handling. But use standard TC functions. First, TC downloads a file from plugin, runs an editor and waits for editor process exits. Then, after process exits, TC checks file modification and if file was changed it ask for file upload back to plugin. The only functions made by plugn: download file and upload file.
In your case, TC wait for script process exiting thinking this is an editor, end when your script exits before real editor, TC think file was not changed and do not suggest uploading back to plugin.
So, you should modify your script to wait until real editor process exit.
I understand your way of reasoning but I think you should reconsider adding your own editor handling and settings, and here's why.

Your plugin requests TC to upload back if the edited value has changed, and relies on TC to _always_ know when the value has changed indeed. However, TC can't always know, for instance, when there is a middleman in between TC and the editor TC can't know that the value has changed (unless the middleman does something special - see #1 further down).

The middleman case is more frequent than one might think. I use F4Menu.exe as my middleman - and I'm pretty sure that several other users in this forum do also. Other users favor other middlemen, this very forum section discusses at least three different F4 middlemen. When any such middleman is involved TC can't know that the editor is still running, so your plugin can't update a changed value.

Who is in a position to fix this situation; the user, the middleman, your plugin or TC? I think your plugin is in the best position (and interest).

Possible solutions I can think of:
1) user change the middleman so that middleman waits for editor to exit
2) you disable the F4 edit function in your plugin
3) you keep the F4 edit function but handle it within your plugin

IMO, option #1 is unreasonable from a user's standpoint because in most common usage cases users don't need for the middleman to wait for the editor to exit - and they don't want to keep the middleman process running unnecessarily.
Waiting for the editor to exit is only needed when TC has to do something after the editing has finished. In your case TC needs to handle the changed value back to your plugin, and this is why your plugin should care about the robustness of the whole chain of events.

I would argue the same of any plugin which expects to be handled changed data back from TC, not just of your plugin.

IMO, option #2 is quite reasonable. After all a user can already change the value by double-clicking it.

Anyway, thank you for your plugin, I enjoy using it.

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-06-01, 14:38 UTC

2sgp
I understand your wishes to make your jobs in the same manner as you imagine them. But the reality is in fact this is the File System plugin. With all limitations inflicted by TC plugin interface. My plugin know about changes in the external file not more than TC knows. Just keep in mind you work with usual files. Did you ever seen a FS plugin which handles file changes with dummy editors? Did you seen this tricky editors can edit files inside an archive and pack changed file back to the archive? Let me know, if you know such.

I can not disable variables editing by F4 because If you edit a variable by F4 you can see changes immediately. But you can not use dummy editors. So, you can edit variable by pressing Enter or Double-Click, but in this case you can not see changes immediately. This is the TC pugin limitations. And I can not satisfy one group of users who want to use dummy editors ignoring interests of another group of users who do not use dummy editors. I will glad to satisfy all of them, but I can not to do this at this moment, so I provide a choise what to use in you case: edit by F4 or edit by Enter and press F2 after editing.

Saying in technical language, I can try to use some tricks and dog-nails to make some magic and guess what user wants. But there is no guarantee this tricks will work in future versions of TC because they are undocumented and unsupported, and I can use them on my own risk. But I want not to risk by stability and compatibilty just for please today wishes. You always may ask Christian to extend the plugin interface :)

speller2
Junior Member
Junior Member
Posts: 72
Joined: 2009-01-26, 13:49 UTC
Location: Russia

Post by *speller2 » 2012-06-01, 15:00 UTC

Volatile variables
I will implement this variables support in next release

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp » 2012-06-01, 18:10 UTC

speller2 wrote:But the reality is in fact this is the File System plugin. With all limitations inflicted by TC plugin interface.
OK, we live in reality :) It's OK, I'll gladly take your plugin as it is, thank you.

And even though TC's plugin interface has some limitations, I'm constantly amazed at the huge numbers of very useful plugins that are available. I know not of any other file manager that can do the same.
Did you ever seen a FS plugin which handles file changes with dummy editors? Did you seen this tricky editors can edit files inside an archive and pack changed file back to the archive? Let me know, if you know such.
No, I didn't see one. But this is what I've seen, and this trick works with your plugin too, I just tested it! I use the Syn2 wlx plugin, and when I press F3 in your plugin Syn2 starts. Then I can edit the envvar value with Syn2, exit Syn2 and TC updates the value back into your plugin. Sweet!
so I provide a choise what to use in you case: edit by F4 or edit by Enter and press F2 after editing.
Fine. And F3 is even another choice.
So I'll edit with F3 and Syn2 or with Enter and F2 as needed.

Post Reply