Setting environment variables automatically? - Microsoft Windows

This is a discussion on Setting environment variables automatically? - Microsoft Windows ; In Windows XP, I don't see an autoexec.bat file anymore. The new procedure to create or modify environment variables globally seems to be to use the "System Properties" dialog (e.g. right-click My Computer, properties, Advanced, Environment Varibles). This can be ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Setting environment variables automatically?

  1. Setting environment variables automatically?

    In Windows XP, I don't see an autoexec.bat file anymore. The new
    procedure to create or modify environment variables globally seems to
    be to use the "System Properties" dialog (e.g. right-click My Computer,
    properties, Advanced, Environment Varibles).

    This can be tedious if I have a long list of environment variables to
    set. Is there any way they can be input using a text file or
    script-like approach, so they can be copied and pasted or automatically
    processed?

    I tried searching the registry for their location then creating a .reg
    file to import, but for some reason it didn't work.


  2. Re: Setting environment variables automatically?

    worker8@gmail.com wrote:

    >In Windows XP, I don't see an autoexec.bat file anymore. The new
    >procedure to create or modify environment variables globally seems to
    >be to use the "System Properties" dialog (e.g. right-click My Computer,
    >properties, Advanced, Environment Varibles).
    >
    >This can be tedious if I have a long list of environment variables to
    >set. Is there any way they can be input using a text file or
    >script-like approach, so they can be copied and pasted or automatically
    >processed?


    You can still use the SET command, f. e. via a batch file that runs
    when Windows starts. Put a shortcut for the file to the AUTOSTART
    submenu of the Start Menu.

    --
    (tm)

  3. Re: Setting environment variables automatically?

    worker8@gmail.com wrote:

    > In Windows XP, I don't see an autoexec.bat file anymore. The new
    > procedure to create or modify environment variables globally seems to
    > be to use the "System Properties" dialog (e.g. right-click My Computer,
    > properties, Advanced, Environment Varibles).
    >
    > This can be tedious if I have a long list of environment variables to
    > set. Is there any way they can be input using a text file or
    > script-like approach, so they can be copied and pasted or automatically
    > processed?
    >
    > I tried searching the registry for their location then creating a .reg
    > file to import, but for some reason it didn't work.


    It should have worked. For machine variables:

    REGEDIT4

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Sessio n Manager\Environment]
    "VARIABLE1"="VALUE1"
    "VARIABLE2"="VALUE2"

    etc.
    (Note that [HKEY_LOC ... \Enviroment] should be one line, it may be
    wrapped here.)

    For user variables:

    REGEDIT4

    [HKEY_CURRENT_USER\Environment]
    "VARIABLE1"="VALUE1"
    "VARIABLE2"="VALUE2"

    etc.

    --
    Olof Lagerkvist
    ICQ: 724451
    Web: http://here.is/olof


  4. Re: Setting environment variables automatically?



    Thorsten Matzner wrote:
    > worker8@gmail.com wrote:
    >
    > >In Windows XP, I don't see an autoexec.bat file anymore. The new
    > >procedure to create or modify environment variables globally seems to
    > >be to use the "System Properties" dialog (e.g. right-click My Computer,
    > >properties, Advanced, Environment Varibles).
    > >
    > >This can be tedious if I have a long list of environment variables to
    > >set. Is there any way they can be input using a text file or
    > >script-like approach, so they can be copied and pasted or automatically
    > >processed?

    >
    > You can still use the SET command, f. e. via a batch file that runs
    > when Windows starts. Put a shortcut for the file to the AUTOSTART
    > submenu of the Start Menu.


    Nope. I created a file containing this:

    SET TESTSTARTUP="test startup"

    and put a shortcut to it in the Startup folder of the Start Menu (I
    assume you meant that instead of AUTOSTART?), and after restarting the
    computer TESTSTARTUP was nowhere to be found.


  5. Re: Setting environment variables automatically?

    You're right, that did work. Very strange.

    One difference between what I did and what you suggested is the
    registry file I exported (before modifying and importing it) started
    with:

    Windows Registry Editor Version 5.00

    instead of:

    REGEDIT4

    Though I can't imagine why that would prevent importing.

    Another strange thing I noticed is that when I copied and pasted your
    user variable example, it pasted as:

    [HKEY_CURRENT_USER\Environment-]

    instead of:

    [HKEY_CURRENT_USER\Environment]

    even though it looks like the latter on the screen. If you look at the
    HTML of your post it has an extra bit of code between the "t" and "]".
    I don't know what that's about (a bug somewhere, probably), but it
    would have made a difference as to whether importing worked.


  6. Re: Setting environment variables automatically?

    worker8@gmail.com wrote:

    > Nope. I created a file containing this:
    >
    > SET TESTSTARTUP="test startup"
    >
    > and put a shortcut to it in the Startup folder of the Start Menu (I
    > assume you meant that instead of AUTOSTART?), and after restarting the
    > computer TESTSTARTUP was nowhere to be found.


    No, because that only did set the variable in the cmd process that were
    executing that batch file. The SET command in cmd.exe does not change
    any registry settings etc, it only changes the value of the variable in
    the current cmd.exe process.

    --
    Olof Lagerkvist
    ICQ: 724451
    Web: http://here.is/olof


  7. Re: Setting environment variables automatically?

    worker8@gmail.com wrote:

    > You're right, that did work. Very strange.
    >
    > One difference between what I did and what you suggested is the
    > registry file I exported (before modifying and importing it) started
    > with:
    >
    > Windows Registry Editor Version 5.00
    >
    > instead of:
    >
    > REGEDIT4
    >
    > Though I can't imagine why that would prevent importing.


    If they start with "Windows Registry Editor Version 5.00" they will only
    work in Windows 2000 and later and the text must be coded using Unicode
    (you can select text coding when you save in notepad). If they begin
    with REGEDIT4 they work with all Win32 versions of regedit.exe.

    > Another strange thing I noticed is that when I copied and pasted your
    > user variable example, it pasted as:
    >
    > [HKEY_CURRENT_USER\Environment-]
    >
    > instead of:
    >
    > [HKEY_CURRENT_USER\Environment]
    >
    > even though it looks like the latter on the screen. If you look at the
    > HTML of your post it has an extra bit of code between the "t" and "]".


    I did not post in HTML but in plain text and there is no '-' between
    Environment and ].

    > I don't know what that's about (a bug somewhere, probably), but it
    > would have made a difference as to whether importing worked.


    If you see any HTML code somewhere it could be something generated by
    your newsreader or something, I don't know.

    --
    Olof Lagerkvist
    ICQ: 724451
    Web: http://here.is/olof


  8. Re: Setting environment variables automatically?

    > If they start with "Windows Registry Editor Version 5.00" they will only
    > work in Windows 2000 and later and the text must be coded using Unicode
    > (you can select text coding when you save in notepad).


    Well, I'm using Windows XP and it seems to save as unicode by default
    when it's exported as unicode, so I still don't understand why it
    wouldn't import the first time. Oh well.


+ Reply to Thread