There is plenty of areas to use this. For me, I use vb scripts on one of my software so users can make their own start up and shutdown scripts. And here is how to implement it into your application.
static void Main(string args)
Console.WriteLine("Script info initializing…");
Process vbScript = new Process();
vbScript.StartInfo.FileName = @"cscript";
vbScript.StartInfo.WorkingDirectory = @"c:\scripts\";
vbScript.StartInfo.Arguments = "hello.vbs";
vbScript.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
vbScript.WaitForExit(); // Remove if you don’t want the script to finish before continue
First we use the system.diagnostic to create a new process.
With the startInfo.FileName we type in the Windows Script Host (cscript).
Next line is just the working directory, where we work with our script files.
The script itself will be an argument for the script host.
WaitForExit, this one make sure the script is done before continuing with the c# application. If it is not needed for the application to wait for the script to exit, just remove that part.
x=msgbox("Welcome to this script" ,0, "Welcome")
You can start as many instances of the script as you like. Just run the vbScript.Start() several times to start it more than once.
And that’s it really.
Posted in C#, Programming, Uncategorized, VB Script