Is it possible to execute a specific sub in a vbs file from a c# application?
I have looked at creating a Process and then launching it but can not find a way to specify which particular sub in the script file should be executed. Is there a way to specify this or is there a better way of doing it?
A vbs could look something like the sample below. What I want is from the C# code to launch either test1 or test2.
Public Sub test1
msgbox "Hey1"
End Sub
Public Sub test2
msgbox "Hey2"
End Sub
When using Visual Basic (without the .Net) I used the Script Control for this.
This page contains some documentation how to call it from good old VB.
Syntax looks something like this:
Result = ScriptControl.Run("Name", arg1, arg2, ... argn)
Edit (after reading comment): If you do not need the VBScript to run in your context (if you do not share objects), you could create a small application that runs the script out-of-process. Your main app is 64 bit, the helper app is 32-bit. You can still pass simple parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With