unfortunate that there is no counterpart to the Linux `export` command RRS feed

  • General discussion

  • The lack of any equivalent to the Linux `export` command substantially reduces the utility of Windows batch scripts.  There is a mechanism for changing an environment variable in the registry, but not one for changing an environment variable in the environment of the shell from which the script was invoked.  I've heard the explanation that it would be bad form to allow this, but Linux developers have depended on this capability for years and I've never seen any harm come from it.  Note: Users would still be limited to changing environment variables only in their own environments.  It might make sense to add a security setting that would allow the user to choose whether this behavior is (a) considered dangerous and should be automatically blocked, (b) getting a case-by-case warning and prompt, and (c) always allowing scripts to change environment variables in the parent script.
    Monday, February 3, 2020 3:21 AM

All replies

  • Everything you are posting already exists in Windows and has since forever.  

    I think you need to do a little homework to learn how these computer operating systems work.  I suggest starting with one of the hundres of boks written that teach how Windows works and how to use it.

    Also the batch shell is old and is deprecated.  Windows has many much better shells and the best Windows shell has been ported to Linux and is now becoming the most popular Unix shell.

    C'mon.  This is the 21st century.  You arguments were invalid in the last millennium and still invalid in this millennium.

    All environment variables can also be changed from teh batch shell.  This has always been true.  If you even took the 15 minutes it takes to read the instructions and commands you would know this.

    cmd /?


    Monday, February 3, 2020 5:45 AM
  • Oh = you can also run Linux commands on Windows directly.


    Monday, February 3, 2020 5:48 AM
  • Your tone is unnecessarily hostile.  Also, you might have taken one minute to read my e-mail more carefully.  I'm talking about the ability to change an environment variable in the parent process' frame.  There is a huge number of posting that state that this can't be done.

    Tuesday, February 4, 2020 5:22 AM
  • It appears from the documentation that one must run an entirely different shell to get these capabilities.  I personally like Linux, but most of the users with whom I work would not be comfortable with a Linux shell.



    Tuesday, February 4, 2020 5:25 AM
  • It is possible to change an environment variable in the current procsss, the user variables and teh system variables.  Even Unix cannot change a variable in a parent process from a child process.

    Process isolation is normal in all modern operating systems.

    My annoyance is at your need to complain about things as if you absolutely know what you are talking about hen your complaint shows you have very little formal understanding of either operating system.

    If you have a question please ask it.  If you just have a complaint then you have complained except this is not the correct plaqce to complain about Windows. Her eis wher complaints are to be lodged. UserVoice


    Tuesday, February 4, 2020 6:47 AM
  • Environment variables are per-process on Windows, and are automatically inherited from the process that started them.

    What you have written in your statement (I don't see a question) is how it works on Windows, and has since its inception. Unless I'm misunderstanding. Please post a sample set of commands that you are using in PowerShell (or cmd.exe) that shows what specifically doesn't work and your expected output.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, February 5, 2020 9:07 PM