Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-02-19
4
Medium Priority
?
261 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 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
This article is about my experience upgrading my consulting machine to Windows 10 Version 1709 (The Fall 2017 Creator Update)
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

971 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