Solved

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

Posted on 1998-02-19
4
254 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

830 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