Solved

How to make an NT startup script set system/user environment variables?

Posted on 1998-02-19
4
251 Views
Last Modified: 2013-12-28
Instead of using the System applet, I'd like to create a "global" script to set System environment variables, and individual user scripts to set User environment variables.  

I tried adding a login script for a particular user (via User Manager | Profile | Login script name).  E.g.,

    script.bat:
                 set varx=hello

The script executes, but the assignment doesn't stick, probably because it lasts only during the brief life
of the DOS window that it runs in.

So, how can I set up the environment for a
particular user -- and how can I set the System
environment for all users, using scripts,
not the System applet?

Thanks in advance.
0
Comment
Question by:elfield
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Dimitri earned 50 total points
ID: 1790705
SETX.EXE is a utility that comes with NT Workstation or Server Resource Kits.  This lets you set global environment variables and works the same as the SET command.

you can find it in the I386\FILEBAT directory on the CD.  I'm sure you can find it on the Microsoft www site as well.
0
 

Author Comment

by:elfield
ID: 1790706
Thanks for letting me know about the setx command.  But it's not quite what I need because it permanently modifies the environment.  For example, using this setx in a logon script
would increase PATH each time the user logged in:

    setx %PATH%;somedirectortory

Instead I need to run a script that builds on the existing system and user environment without changing it permanently.

Is there a way?




I need to run a script that
0
 
LVL 1

Expert Comment

by:Dimitri
ID: 1790707
Hi,

I'm not exactly sure what you mean - you want the variables to exist outside of that initial NT VDM, but not exist permanently?

I'm not sure how you can do that except get your scripts to use SETX to set variables and get the last script to just set the variables you want to keep, and reset the rest.  I don't think you can get environment variables to be "remembered" unless they're set into the master environment.
0
 

Author Comment

by:elfield
ID: 1790708
There are two cases:

1.  User variables:  I'd need permanent and "added" variables.
I can use the System Applet to set the permanent variables.
But I need to set the added variables with a logon script.  The
script can be edited by the user.  For example, the script
may extend PATH:

       set PATH=%PATH%;<usersupplied>

If SETX was used, the PATH would keep growing.

2.  System variables:  SETX is okay here, as is the
system applet.  

In DOS, the autoexec.bat works fine (for both "system"
and "user"), because you never leave the initial DOS
session.  But NT seems to launch a DOS box to run a login
script.  When that DOS box is destroyed, so are any environment
variables that it set.  Perhaps NT has some other scripting
mechanism that doesn't run in a DOS box.  If yes, then
that mechanism would allow environment variables to be
set at the beginning of a user session.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now