Solved

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

Posted on 1998-02-19
4
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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.

626 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