Hi Shadow fax,
Use scriptArgs and doScript
var VBScript = 'app.scriptArgs.SetValue "myResult", "Like This"'; app.doScript(VBScript, ScriptLanguage.visualBasic); alert(app.scriptArgs.getValue("myResult"));
Message was edited by: Trevorׅ P.s. I didn't read what you read about the alert stuff but HTH anyway
@Travor, thanks for your reply
I forgot to mention in the question but, this script is for Windows. And I guess, doscript is for Macintosh right?
If I'm right, how could I get the output of vbscript back in my extendscript?
Wrong, doScript is for both Mac and Windows
So it should work for you
Give it a go
@Trevor, Thanks again, but it says method not found "app.doScript"
Another thing- my vbscript actually returns the network's mac address, so your method will work with this right?
This will be my vbscript-
dim WMI: set WMI = GetObject("winmgmts:\\.\root\cimv2")
dim Nads: set Nads = WMI.ExecQuery("Select * from Win32_NetworkAdapter where physicaladapter=true")
for each Nad in Nads
if not isnull(Nad.MACAddress) then Wscript.Echo Nad.description, Nad.MACAddress
The capitalization is app.doScript and not app.doscript that is if you are trying to get a jsx script to run and access a string from from a vbs script.
When defining the VBscript for multiline scripts the easiest method is to use triple quotes
VBscript = """dim WMI: set WMI = GetObject("winmgmts:\\.\root\cimv2") dim Nads: set Nads = WMI.ExecQuery("Select * from Win32_NetworkAdapter where physicaladapter=true") dim nad for each Nad in Nads if not isnull(Nad.MACAddress) then Wscript.Echo Nad.description, Nad.MACAddress next"""
when using the scriptArgs you can either make a loop of them and send the string value of each one something like this
For (n = 0 .........
myArg = "myArg" & n
myStringToPassOver = "Shaddow Fax " & n
app.scriptArgs.SetValue myArg, myStringToPassOver
or probably better to make a long comma or something else separated string and pass it over after the loop
var VBScript = """myArg = "" For n = 0 To 15 myArg = myArg & "Shaddow Fax " & n & "," Next app.scriptArgs.SetValue "myResult", myArg """; app.doScript(VBScript, ScriptLanguage.visualBasic); var myResult = app.scriptArgs.getValue("myResult").replace(/\,$/,"").split(","); // if neaded use "replace" to remove final "," and "split" to convert into an array alert(myResult.join("\r")); // alert the array
The above script is a jsx script that runs a vbs
If you want a vbs script to run and access a string from from a jsx script then you would use xxx.DoScript see the sample from the manual below.
P.s.Please mark the question as answered, thanks
Although I quite possibly make it into the worlds top 2 billion vb programmers I can't help you with your specific script which is trying to get the network mac address.