Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Several part series to implement Internet Explorer 11 Enterprise Mode
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

708 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

13 Experts available now in Live!

Get 1:1 Help Now