Object required: 'wscript'
I'm running the vbscript from within a Delphi app.
This is why your script is failing. The wscript object is only defined when the script is run by wscript.exe. To do what you are attempting, you need to implement your own object and provide it to the script environment for the script code to access when needed.
Assuming you are using IActiveScript to run your script, you can write a COM Automation object that implements the IDispatch interface, and then you can create an instance of that object and give it to the IActiveScript.AddNamedItem() method before then calling IActiveScript.SetScriptState() to start running the script.
For example, write an Automation object that exposes its own CreateObject() method, give it to AddNamedItem() with a name of App, and then the script can call App.CreateObject(). Your CreateObject() implementation can then create the real requested object and hook up event handlers to it as needed. To fire events back into the script, use the IActiveScript.GetScriptDispatch() method to retrieve an IDispatch for the desired procedure defined in the script, and then use IDispatch.Invoke() with DISPID 0 and the DISPATCH_METHOD
flag to execute that procedure with the desired input parameters.
Your object can implement any properties and methods that you want the script to have access to.