Benjamin Jones
Benjamin Jones

Reputation: 997

Setting Variable with VBS to output in Batch

I have a VBSript that outputs a string. Could I set that string as a environment variable?.

Example: Say my script creates the string: abcstring . Well I want to add string output as the variable: StringVar

So if I enter %StringVar% in a batch command it will output: abcstring

Is this possible?

Upvotes: 1

Views: 285

Answers (1)

Bond
Bond

Reputation: 16311

If you create it as Volatile, it will be available after your VBScript terminates (actually, until the user logs off).

With CreateObject("WScript.Shell")
    .Environment("VOLATILE")("StringVar") = "This is a string"
End With

Upvotes: 1

Related Questions