Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

set system path and eviroment variables

11 views
Skip to first unread message

Eric

unread,
Feb 6, 2002, 11:26:24 AM2/6/02
to
Hi,

I am trying to replace the batch scripting on our server
with wsh, namely vbscript. Our nightly processing runs a
batch script which set enviroment variables before running
certain applications. It sets the variables in two ways.

Method 1
set SUMMITHOME=C:\summit
set GROUPID=10

Method 2
set PATH=%SUMMITHOME%\orbix\bin;%SUMMITHOME%\V2.6e4.8
\client\sovb\exe;%SUMMITHOME%\V2.6e4.8\exe;c:\perl\bin;%
PATH%

after such variables are set the program is called. How
can I do the same type of setting in vbscript?

Thanks
Eric

Muhammad Arrabi (MS)

unread,
Feb 6, 2002, 6:31:55 PM2/6/02
to
Hello Eric,
I'm really glad to see you abandoning the batch files! That's the spirit!
You said you're working on a server, and that' good news. Mainly, because
there are two ways to modify environment variables - relevant to your
system:
1- In NT/2000/XP:

Environment variables have four levels: system, user, volatile, and
process.

System environment variables are shared for the whole computer (all user
accounts - saved per machine).
User environment varialbes are specific for the user account (saved per
user).
Process environment variables are specific for the process - and any changes
will be lost when the process terminates.
Volatile environment varialbes (warning: never used them - all what I know
are rumors) are fixed per log-in session. So, they are gone once you log-out
your user account.

The code to access them:

objShell = new ActiveXObject("WScript.Shell");
objEnv = objShell.Environment("System");//you can say system, user, process,
volatile
objEnv("path") = "blah blahb blah";
WScript.Echo(objEnv("path"));

2- For Win 95/98/ME, it's more complicated. There are two ways that
complement each other:

1- Winset.exe: This is a command line utility that comes with the
windows CD (95/ME) (I've never used it - but it should work). This command
will set environment variables for the duration of the windows session (when
you restart you lose the changes). To use it from script, you should execute
a command line:
objShell.Run("c:\\winset datapath=d:\\data")

2- Autoexec.bat: The old nice autoexec.bat. Changes here need a
restart to take effect - but they stay.

Since you're working on server, you must have NT/2K => should be all fine.

Hope that helps,

Muhammad Arrabi (MS)


"Eric" <jonp...@hotmail.com> wrote in message
news:08c401c1af2b$04fa6da0$9be62ecf@tkmsftngxa03...

0 new messages