set system path and eviroment variables 
Author Message
 set system path and eviroment variables

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



Mon, 26 Jul 2004 00:26:24 GMT  
 set system path and eviroment variables
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)


Quote:
> 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



Mon, 26 Jul 2004 07:31:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Expanding SYSTEM %PATH% with embedded SYSTEM environment variable problem

2. Increase length of system Path environment variable?

3. How to set the PATH variable?

4. set environment variable path

5. Setting System Environment Variables

6. Adding Environmental Variable to System Variables thru VB

7. Object variable or With block variable not set (Error 91)

8. UNC Path and the local System Account

9. Object variable or With Block variable not set

10. Object variable or with block variable not set

11. mimemap - system cannot find the path specified error

12. Setting Path

 

 
Powered by phpBB® Forum Software