Hi,

I want to define and set variables in one script, but have value contained
in those variables available in other scripts that run after it...
Here is a little more detail : I have 1 logon script that calls upon 5 other
scripts, depending on group membership and other conditions...
1 of those 5 scripts sets variables for some applications, the problem is
that the value contained in those variables are not available to other
script...

Here is an example of the script containing the variables :
Public Appvar1 ( chosen public instead of DIM, thought it would make it
available to other scripts )
Appvar1 = "123456"



In other scripts, I put the content of this variable into en environment
variable :

Set WshEnv = Wshshell.Environment("User")

WshEnv("NameApp1") = Appvar1

if I put both the first part and second part in the same script, it works,
my problem is that the script containing the variables will be modified
frequently by about 20 different people, but don't want them to modify and
mess up the other more complex script...

Could some one tell me how to set this...
Is it with : Wshshell.Environment("PROCESS") or some other way...

Thanks !!!


--
--
Houman Yahyaei ( CCNA, MCSE Win 2000/NT 4.0, MCT )
IT Training and Consulting
www.formationhy.com
Houman@formationhy.com

Re: Variables set in one script to be avaible in other scripts by Torgeir

Torgeir
Sat Jan 17 17:57:27 CST 2004

Houman Yahyaei wrote:

> Hi,
>
> I want to define and set variables in one script, but have value contained
> in those variables available in other scripts that run after it...
> Here is a little more detail : I have 1 logon script that calls upon 5 other
> scripts, depending on group membership and other conditions...
> 1 of those 5 scripts sets variables for some applications, the problem is
> that the value contained in those variables are not available to other
> script...

Hi

As long as the main script is the one that starts the other scripts, using the
process environment will work. Create the two scripts below and run the main
script to see this (if you change the name/path of C:\SecondScript.vbs, update
the main script's Run statement accordingly).


-------------------- Main script --------------------

Set Wshshell = CreateObject("WScript.Shell")

Set oProcessEnv = Wshshell.Environment("PROCESS")

Appvar1 = "abcxyz"
oProcessEnv("NameApp1") = Appvar1

Wshshell.Run "wscript.exe C:\SecondScript.vbs", 1, False



---------------- C:\SecondScript.vbs ----------------

Set Wshshell = CreateObject("WScript.Shell")

MsgBox "Content off NameApp1 (variant 1): " _
& Wshshell.ExpandEnvironmentStrings("%NameApp1%")

Set oProcessEnv = Wshshell.Environment("PROCESS")
MsgBox "Content off NameApp1 (variant 2): " & oProcessEnv("NameApp1")


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter