Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Replacement for VBScript (interop.msscriptcontrol.dll) DLL

We are using interop.msscriptcontrol.dll to execute simple VBScript variables code ("Today - 1" kind of stuff). Our application is non-COM components except for this one. We have searched for a .Net replacement of VBScript, but we've been unable to find one.

Is there a VBScripting replacement for .Net?

like image 952
John Cruz Avatar asked May 13 '26 01:05

John Cruz


2 Answers

In the following example, I will make the WebBrowser control evaluate the VBScript expression "Now - 1" and embed the result in the WebBrowser's document.title so I can fetch it in C#:

WebBrowser wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(
    (object _sender, WebBrowserDocumentCompletedEventArgs _e) =>
    {
        MessageBox.Show(wb.Document.Title);
    }
);
wb.DocumentText = @"
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
<SCRIPT language=""VBScript"">
document.title = Now - 1
</SCRIPT>
</HEAD>
<BODY/>
</HTML>";

Obviously, this approach suffers from:

  • the results are processed as strings
  • the results require asynchronous handling
  • poor code injection can lead to invalid results
  • it may not perform well and could lead to creating a bottleneck in your app

My gut feeling is this approach is potentially worse than the approach you're currently using.

like image 161
Stephen Quan Avatar answered May 16 '26 01:05

Stephen Quan


I ended up using the free Codefluent runtime engine to replace msscriptcontrol.dll:

http://www.softfluent.com/products/codefluent-runtime-client

like image 27
John Cruz Avatar answered May 16 '26 01:05

John Cruz