0

From VB.net we can execute VBScript code by using following line:

System.Diagnostics.Process.start("AbsolutePathofVBScriptfile")

But how can one call a specific function present in vbscript from VB.net code? I searched for that but couldn't figure it out. Some things I found were IActiveScript, MSScript.ocx...

1 Answer 1

2

I'm not sure that this can be done, as you are operating in two totally different domains.

That line of code you present does nothing different than if you double-clicked the vbscript file.

I've done next to no vbscript programming, but what about this... Create another script file (stub) that does nothing but call a function (subroutine) in your main, library file. Then, invoke the stub from the VB.net application.

library.vbs

Function LibraryFunction(oValue)
    Wscript.Echo "LibraryRoutine Running!"
End Sub

...

stub.vbs

' Essentially "Import" the library script
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("procedures.vbs", ForReading)
Execute objFile.ReadAll()

' Call the appropriate function from library
LibraryFunction(4)

VB.net

System.Diagnostics.Process.start("stub.vbs")

Functions, Subroutines, and How to Call Them From Other Scripts

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.