1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to get Take Command to read in all current system environment variables that CMD.EXE sees?

Discussion in 'Support' started by daniel347x, Apr 28, 2011.

  1. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    Hello (and thanks for taking all my questions) -

    I would like the Take Command tab (TCC prompt) to see all recent changes to the System environment variables, even after Take Command is restarted.

    I am aware of the "Update Environment on System Change" option, and I have this selected. This works insofar that if I *edit* a system environment variable while Take Command is running, after about 20 seconds the change is reflected in the TCC open (and new) tabs.

    However, if I exit Take Command and restart, the changes are lost - I then have to make a "dummy" change to the desired system environment variable (and then remove the dummy change) in order for the TCC tabs to pick up the environment variable in its new state.

    Is it possible for Take Command to read the current state of the system environment variables, as seen by CMD.EXE, when it runs?

    Thanks,
    Dan.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    This is actually TWO options -- one in TCMD, and one in TCC. You need to select both of them.
     
  3. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    I've actually selected *both* the option in TCMD, and the option in TCC, for "Update Environment on System Change" ... it does not seem to work. When you quit, then restart, the main Take Command application, new tabs do not show any system environment variable changes that have been made through the system control panel (without the computer being restarted).

    I can triple-check this if you think I'm wrong - but I carefully double-checked it before I submitted my posting a few days ago.

    It's valuable to have this feature as I add and remove JAR files from the system CLASSPATH for Java development - it's a pain to have to make a "dummy" change to the CLASSPATH (and then immediately remove it) just to get TakeCommand to pick up the proper value (assuming I've quit & restarted TakeCommand).

    Thanks,
    Dan.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    On Mon, 02 May 2011 17:53:24 -0400, daniel347x <> wrote:

    |I've actually selected *both* the option in TCMD, and the option in TCC, for "Update Environment on System Change" ... it does not seem to work. When you quit, then restart, the main Take Command application, new tabs do not show any system environment variable changes that have been made through the system control panel (without the computer being restarted).
    |
    |I can triple-check this if you think I'm wrong - but I carefully double-checked it before I submitted my posting a few days ago.
    |
    |It's valuable to have this feature as I add and remove JAR files from the system CLASSPATH for Java development - it's a pain to have to make a "dummy" change to the CLASSPATH (and then immediately remove it) just to get TakeCommand to pick up the proper value (assuming I've quit & restarted TakeCommand).

    "Update ..." works as I would desire (almost). If, while TCMD is running, I add
    a variable to the user environment with the cp-applet), then TCMD sees it right
    away (evidenced by the fact that a newly-started tab gets the added variable.
    But an already-running TCC doesn't make the change right away ... it seems to
    wait until the next prompt is issued. The two commands below were issued
    consecutively, both after I set foo=bar in the user environment via the system
    cp-applet.

    Code:
    v:\> set
    TCMD=D:\TC12\tcmd.exe
    TCMDVER=12.10.64
    _TCSTART=D:\tc12\TCSTART.btm
    
    v:\> set
    foo=bar
    TCMD=D:\TC12\tcmd.exe
    TCMDVER=12.10.64
    _TCSTART=D:\tc12\TCSTART.btm
    [That makes some sense (don't want to change the env of a running batch file)
    but it could be argued otherwise. Couldn't you make the change immediately as
    long as TCC isn't running a batch file?

    And (Rex) does TCC exclude itself from acting on WM_SETTINGSCHANGE when you SET
    /u|/v|/s|/d? Other instances seem to become aware (after a new prompt, see
    above), but the instance that set it doesn't. Is "/E" necessary?
     
  5. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    vefatica - My issue is that when TC itself is *quit* and then *restarted*, that tabs do not have an environment that includes changes previously made via the system control panel to environment variables, even though *new tabs* reflect changes made to environment variables *while TC is running* as long as you don't quit Take Command.

    This requires that I either leave TC running, which I sometimes forget to do, or that I make a dummy change in the environment variables to get new tabs in TC to notice the change "again". In any case, it leaves me constantly having to check the value of the environment variables within TC just to confirm it's picked up the changes, rather than being able to make a change, shut down all tabs and count on TC always having the new values.

    Thanks,
    Dan.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    On Mon, 02 May 2011 21:20:57 -0400, daniel347x <> wrote:

    |vefatica - My issue is that when TC itself is *quit* and then *restarted*, that tabs do not have an environment that includes changes previously made via the system control panel to environment variables, even though *new tabs* reflect changes made to environment variables *while TC is running* as long as you don't quit Take Command.
    |
    |This requires that I either leave TC running, which I sometimes forget to do, or that I make a dummy change in the environment variables to get new tabs in TC to notice the change "again". In any case, it leaves me constantly having to check the value of the environment variables within TC just to confirm it's picked up the changes, rather than being able to make a change, shut down all tabs and count on TC always having the new values.

    When you start it, it gets the environment of its parent. I'll say that again
    ... a program inherits the environment of the program that started it. For best
    results, start TCMD from Explorer (or an Explorer shortcut).

    Experiment: Verify that "foo" is not set in the user environment. Start TCMD.
    Via control panel, set foo=bar in the user environment. Now, after two SETs,
    the TCC running in TCMD should see the new variable. And newly-started tabs
    will see it right away. Close TCMD. Start TCMD again (using Explorer). You
    should still see foo=bar.

    If that's not what you're talikng about, please give a detailed experiment.
     
  7. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    Vince -

    I am referring here to a *change* in an existing environment variable, rather than the addition of a new one.

    If I follow this sequence of steps:
    (->) Run TC
    (->) Change an environment variable through CP
    (->) Issue the 'set' command twice
    (->) (Note - the change in the environment variables is now observed)
    (->) Quit TC
    (->) Start TC
    (->) The change in the environment variable is *not* observed.

    I've just confirmed this.

    Thanks,
    Dan.
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    On Mon, 02 May 2011 22:51:46 -0400, daniel347x <> wrote:

    |I am referring here to a *change* in an existing environment variable, rather than the addition of a new one.
    |
    |If I follow this sequence of steps:
    |(->) Run TC
    |(->) Change an environment variable through CP
    |(->) Issue the 'set' command twice
    |(->) (Note - the change in the environment variables is now observed)
    |(->) Quit TC
    |(->) Start TC
    |(->) The change in the environment variable is *not* observed.
    |
    |I've just confirmed this.

    That is not what I see. I am starting TCMD via Explorer and the second time,
    TCMD sees the same **changed** variable it saw after the first time.

    How are you starting TCMD?

    What if you leave out step 1 above ... just change a variable and then start
    TCMD? Are you saying TCMD never sees changes made via cp-system? Then I'd
    suspect you're starting TCMD from an app which **doesn't** update its
    environment.
     
  9. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    WAD. You might be in the middle of a command. Remember that TCC is a console app, and it does NOT have a message queue!

    WAD -- TCC excludes itself from the update.
     
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    >WAD. You might be in the middle of a command. Remember that TCC is a
    >console app, and it does NOT have a message queue!

    I thought the "TCC.EXE" class window had its own thread and message pump just for reasons like that.
     
  11. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    Vince -

    Thank you so much! That was it. This thread actually resolved an issue that I figured was an issue with TC - but wasn't. I know you mentioned to start TC from within Explorer, and I thought at the time you meant "not from the command line of CMD.exe". It didn't occur to me to realize that I was starting TC from a utility application I have to help organize programs ... it was from within this program (Berokyo) that I have been running TC.

    So indeed, I should have thought more carefully about your comments - running TC from Berokyo does not count as running from Explorer.

    So, I have given up on using my utility program to run TC, and I've just pinned TC to the taskbar. When I run TC from the taskbar icon, it works exactly as you've indicated.

    Excellent - now I can have access to environment variable changes.

    Thanks, and my apologies for the false alarm. I wouldn't have thought of this.

    So, problem solved.

    Dan.



     
  12. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    On Tue, 03 May 2011 00:00:42 -0400, daniel347x <> wrote:

    |So, I have given up on using my utility program to run TC

    You should suggest to the author of that utility that he update its environment
    appropriately (so it will be given to started apps). I did that with the
    PowerPro utility (which I use) years ago. I even wrote the first update routine
    for him; he was happy to include it.
     
  13. daniel347x

    Joined:
    Apr 28, 2011
    Messages:
    13
    Likes Received:
    0
    I will.
    Dan
     
  14. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30

Share This Page