1

A VBScript are loaded within another application, the application thats loading/executing the VBScript are creating an object so it's possible to get and set variables to and from the application loading the VBScript.

In the loaded VBScript I'm reading a variable with the following command:

ApplicationName.GetStringVariable("string1")

I'm executing my C# application from the VBScript with the following commnand:

Set WshShell = CreateObject("WScript.Shell")
Return = WshShell.Run("c:\TestAppDelete.exe", 1, true)

I use the bWaitOnReturn so that the VBScript are running while my other C# application are running. But I can't find a way to access this VBScript object from my C# application. It tells me the object are not existing. This is my C# code:

I'm executing an exe from a VBScript with the following code trying to access the VBScript object:

MSScriptControl.ScriptControlClass sc = new MSScriptControl.ScriptControlClass();
sc.Language = "VBScript";
sc.AddCode("MsgBox ApplicationName.GetStringVariable(\"string1\")");

What am I doing wrong?

1 Answer 1

1

When you run the TestAppDelete.exe you create a fresh new process. When you create a ScriptControlClass you create a fresh new scripting context in your fresh new process. When you add code to that script that uses ApplicationName that object doesn't exist and therefore fails.

Instead of creating a C# .exe consider creating a COM compatible C# .dll instead.

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

1 Comment

Any way to find that specific process and access the object directly?

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.