tags:

views:

25

answers:

2

Hello, is it possible to send variables from C# to a VBScript file? Then send variables back to C# after the script is executed.

Thank you

A: 

You can pass command line parameters to a VBScript file, using the windows scripting host (WScript) - see this for details on the VBScript side. On the C# side, you should use Process.Start and pass in the arguments to the script.

There are several options for returning values, though I do not really like any of the ones proposed here.

You can write values out to a file in your VBScript and have the C# read the content of the file.

Oded
A: 

If you run the VB script from another process (Process.Start(vbScriptFilePath) etc.) than you can send the variables to the start call, as the command line arguments argument. Then, after the process terminates, you can use its ExitCode property. Note that it enables you to get only one value - so if you want to set more than one C# variables using your VB script, you need to use a file\ registry keys etc. to do that.

rursw1