Sean
Sean

Reputation: 3052

How can I execute VBScript in C#

We have a legacy system that allow customer to custmize the workflow by vbscript, for example, the user could write some code like

for each account in accounts {
   Dim acc as Integer
   .....
}

the code inside the {...} is VBScript. and the legacy system is writtern by VB, and use ScriptControl to execute the script directly. Now we are going to upgrade the system to C# .NET 4.5, we want to get rid of the old scriptcontrol but want to keep the scripts from users.

My question is it possible to execute vb script from C#?

Thanks

Upvotes: 3

Views: 16759

Answers (2)

Sean
Sean

Reputation: 3052

finally, we decide to migrate to IronPython instead of VBS, vbs is not supported by microsoft. so it's time for move on

Upvotes: 1

diyoda_
diyoda_

Reputation: 5420

You can execute VBScript from C# code.

Process scriptProc = new Process();
scriptProc.StartInfo.FileName = @"C:\text.vbs";
scriptProc.Start();
scriptProc.WaitForExit();
scriptProc.Close();

There are some important things that you have to consider. Take a look at this answer

Upvotes: 1

Related Questions