sri ranga rajan
sri ranga rajan

Reputation: 3

Is it possible to share a variable(global) between two or more Vbscripts?

Is it possible to share a variable(global) between two or more Vbscripts ?

Example - There are two .vbs programs. "One.vbs" - Public a a = InputBox("Enter your name") MsgBox ("You entered: " & a)

"two.vbs" - MsgBox a

Is it possible that the "two.vbs" will provide the same output(after the one.vbs is executed) ?

Upvotes: 0

Views: 373

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

In that case, the easiest way would be to use a text file to transfer the info:

A.VBS

CreateObject("Scripting.FileSystemObject").CreateTextFile("28341578.txt").Write InputBox("Your name, please!")

B.VBS

WScript.Echo CreateObject("Scripting.FileSystemObject").OpenTextFile("28341578.txt").ReadAll()

Alternatives: Environment variable, registry entry, other file types (Excel, SQLite, ...), a 'real' database.

Upvotes: 1

Related Questions