Jeremy Boyd
Jeremy Boyd

Reputation: 5403

Execute VBScript Function from C# with parameters

How do I call a function inside a VBScript file from C#? The function has 2 parameters.

Upvotes: 0

Views: 6257

Answers (1)

IAmTimCorey
IAmTimCorey

Reputation: 16755

There are a few ways you can do this. The simplest would be to execute the VBScript file from a command line inside C#. You would need to pass your parameters in at the command line, but the code would look similar to this:

System.Diagnostics.Process.Start(@"cscript //B //Nologo c:\yourfile.vbs");

Here are more examples of how to execute command line functions in C#:

http://www.dotnetperls.com/process-start

You can also get more advanced with these methods:

http://msdn.microsoft.com/en-gb/magazine/cc301954.aspx

http://msdn.microsoft.com/en-us/library/ms974577.aspx

Upvotes: 2

Related Questions