slayernoah
slayernoah

Reputation: 4492

Returning a string from a C# console application to VBScript

On one of my VBScripts, I have to call a C# console application.

AFTER the C# application finishes executing (synchronous), I need to get the output of the C# application, which is a string, into the VBScript.

System.Environment.ExitCode in C# only allows an Integer to be returned.

How can I have get the string that is output by the C# application into the VBScript?

I realize that it is possible to save the output of the C# application to a file and read that using VBScript. However, I was looking for something less messy.

Any solutions/suggestions are welcome.

For example: Is there some way to create a DLL and use this to enable a return string value to be passed to VBScript? I am not sure. This is just a thought. Is there a way to create something similar to Shell.Application BrowseForFolder?

Thanks for all your help!

Upvotes: 2

Views: 2104

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564413

You can use a WScript.Shell object to execute the C# process, and then read from it's StdOut filestream.

For details, see this tek-tip on the subject.

Upvotes: 2

Related Questions