views:

552

answers:

4

I'm looking to execute user supplied scripts from my Delphi application.

Is it possible to host the Windows Script Host engine in my application and supply it with scripts to execute? Or, is there a better way to approach this problem?

P.S I'm not looking for third-party components.

+1  A: 

This is entirely possible and there is plenty of code out there that shows how to do this. Check out: http://www.torry.net/pages.php?id=280

Lloyd
Are any of those free? With source? What about hosting the engine directly without any third-party components?
James Couvares
On Torry, any item that is marked with "FWS" means "Freeware with source". A bunch of those packages are marked that way. Some of them look they are all Pascal so the engine is compiled into your app. Others seem to make use of external engines like Lua.
Todd
+2  A: 

I think you're looking for Windows Script Control.

Uros Calakovic
Yes, the Windows Script Control would be the way to go. Redistributables for VBScript and JScript can be obtained for free from Microsoft.
Jason Swager
You don't need any redistributables on WinXP SP1 and further. Only for Win98 and Windows 2000.
Andrei K.
A: 

You don't need any thrid party components for using Windows Script Host. We use it for ten years and have built a huge ERP system around it with more than 1 million of source code lines in VBScript.

You should use Windows Script Control in order to tell to Windows Script Host or just connect directly through known interfaces.

Andrei K.
+1  A: 

Allen Bauer made a blog post about using Active Scripting a few years back. It goes into the theory behind it and links to code on Code Central which supports VBScript and JavaScript, no third party components necessary.

Craig Peterson