2

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!

3
  • 1
    Any particular reason not to use PowerShell for scripting instead of VBScript? It is soooo much easier to call .Net code from PowerShell. Commented Jun 26, 2013 at 23:16
  • Thanks for the reply! This script is being executed from within a 3rd party application which only supports VbScripts. Commented Jul 1, 2013 at 21:15
  • I found a better answer than all those provided here in that link: social.msdn.microsoft.com/Forums/en-US/… Commented Apr 18, 2014 at 20:57

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

11 Comments

For details I'd rather refer to the documentation.
On the C# program, how can I write to the Stdout so that it will be read by the VbScript?
@slayernoah Console.WriteLine writes to standard output.
@ReedCopsey Is there any way we could get it to work the same way without the WScript.Shell object? The environment it runs in doesn't have this object. Thanks!
@slayernoah How are you running VBScript? WScript.Shell is part of the Windows Scripting host, which is what runs VBScript...
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.