Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 83 Next »

Under Construction


The Scriptom documentation is changing to reflect the new Maven build and artifacts.
This is going to take some time. In the meantime, please take what you read with a grain of salt,
and pardon the messiness.
Rest assured that while there will be some restructuring of the documentation, the previous
builds will still be available for anyone who needs them, ongoing, indefinitely.


Scriptom is an optional Groovy module originally developed by Guillaume Laforge. It combines the elegant "syntactical sugar" of Groovy with the power of the Jacob library (Java COM Bridge). Scriptom lets you use ActiveX or COM Windows components from Groovy.  The result is something that looks eerily similar to VBScript - only groovier.

You can use Scriptom to automate Word or Excel documents, control Internet Explorer, make your PC talk using the Microsoft Speech API, monitor processes with WMI (Windows Management Instrumentation), or browse the Windows Registry using WShell - and much more.  Scriptom also provides an easy way to talk to custom VB6 or Microsoft.NET libraries. 

Of course, Scriptom can be used only on Microsoft Windows.

Scriptom is included as an option in the Windows Installer, and Scriptom can be downloaded from this page (see below). The Scriptom codebase is stable and feature-complete.  The Jacob project - Scriptom's foundation - was started in 1999 and is being used in countless production Java applications worldwide.  Scriptom is now in wide use as well, and has proven to be stable and mature. 

Scriptom gives you all the COM-scripting power of Jacob, only it is a lot easier. See Getting Started with COM for some tips to get you started.


The following are required to run Scriptom:

  • Groovy 1.5 or 1.6
  • Java 1.5 or later
  • Windows and Java for x86 or x64 (AMD64) architectures.  Itanium (IA-64) is not supported.

Maven-Generated Documentation

Maven-generated documentation is available at  This contains useful information from the build, including JavaDoc for all projects.


Scriptom is part of the Windows Installer. If you are running Groovy scripts on Windows, you are all set.

"Just the (Arti)facts, Ma'am."

If you are running Groovy outside the Windows Installer, and you aren't using Maven or Grape, you probably just need the pre-packaged JAR files and associated binaries. You've come to the right place.

Note that as of release 1.6.0, the distribution archive is formatted differently.  The new format matches the folder structure needed by the Windows Installer. Source code, build scripts, and documentation are no longer included in the distribution.

  • (star) Scriptom 1.6.0 (4/8/2009) - No new features or bug fixes. Distribution for Windows Installer. Includes only compiled artifacts. Supports Groovy 1.5 and up.
  • Build 12 (12/26/2008) - Full project including source. Supports Groovy 1.5 and up.

Adding Scriptom to a Maven Project

You can add Scriptom to a Maven project. Because there is JNI involved, it isn't quite as simple as adding a dependency, but it is doable. Need to come up with an example of creating an assembly with GMaven.

  1. Add the Scriptom dependency to your Maven project.
  2. Add the Jacob JAR dependency. This JAR must be loaded only once, so if you are working in a server application like Tomcat or GlassFish, you need to ensure that Jacob's JAR is only loaded by the system classloader. Need more explicit instructions on this...
  3. Jacob requires a DLL. It's a JNI project, after all. But Jacob actually supports two versions of the DLL it needs, one for 32-bit x86 systems, and one for the AMD x64 architecture (works with 64-bit Intel chips too). The easiest way to get this to work is to put both DLLs somewhere on the system path. Jacob will automatically pick the one it needs. Need to detail the other ways to specify the Jacob DLL.

Need to detail the TLB projects, constants, etc.

The Old Way to Install (deprecated)...

Download the project archive and extract the files.

  • (thumbs up) Build 12 (12/26/2008) - Scriptom JAR file, Scriptom-1.5.4bX-32.dll, Scriptom-1.5.4bX-64.dll, Java source code, ANT build script, examples, tests, utilities, and documentation.

Install the jar file and DLL file(s) into your project, and optionally install an update from Microsoft:

  1. Add the Scriptom jar file (scriptom-1.5.4bX-XX.jar) into your Java classpath.  It contains both Scriptom and Jacob class files, so you must not include jacob.jar.

    Scriptom contains a full (current) version of the Jacob library. If you are using Jacob directly elsewhere in your project, remove all references to it and use the version built in to Scriptom.

  2. Copy both Scriptom-1.5.4bX-XX.dll files to somewhere on your java.library.path. (usually somewhere on the system 'PATH').

    The Scriptom DLL naming convention allows multiple versions of Scriptom to run on the same machine. However, you can only run a single version of Scriptom JAR in any given project.

  3. To avoid the dreaded java.lang.UnsatisfiedLinkError, download and install one of the following updates from Microsoft: Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)or Microsoft Visual C++ 2005 SP1 Redistributable Package (x64). Scriptom doesn't support the  IA-64 (Itanium) architecture at this time, mainly due to lack of interest. If you are wondering about the different processor architectures, check out the x86-64 wiki. It is usually necessary to install these updates on Windows Server 2003 and Windows 2000, and we've found that it may also be necessary for Windows XP and even Vista.

    A project can only use one version of Scriptom at a time. If you have installed Groovy using the Groovy Windows Installer, you must remove any versions of Scriptom JAR files or replace them with the latest version. A version of Scriptom is installed as part of the Groovy Windows Installer installation.

    Scriptom 1.5 is not supported for Groovy 1.0 and earlier (Scriptom 1.2 is still available). 

Building from Source

The project source is managed by Subversion. The projects are already set up to work with Eclipse, but it isn't hard to get them working with other IDEs, and you can get by with Notepad. The project trunk is located at This is a Maven build. Because the tests are dependent on Windows technologies, there are some rather strange software requirements:

  • Windows XP or later.
  • Visual C# Express 2008 or Visual Studio 2008
  • Java 1.5.x or later. Java 1.6.x recommended.
  • Maven 2.0.9 or better.
  • A Subversion client. I recommend you get one or both of:
    • Tortoise
    • SlikSVN

To build, use the following command line:

The latest build requires Groovy 1.5 or better.

Scriptom includes source files and compiled DLLs (Windows libraries compiled from C++) from Jacob version 1.14.  You don't need to download sources and binaries from the Jacob project on, though you can do so if you need to build the entire project yourself.

To build the project on Windows, run project/build/make.bat.  Since Scriptom is a Windows-specific module, there isn't a shell script for building on other operating systems.

The build process requires Java 1.5 or higher (Java 1.6 recommended) and ANT 1.6.5 or better.

Changes from Scriptom 1.2

Scriptom 1.5 is a substantial upgrade to previous versions of Scriptom, and is not backward compatible.  We hope you will agree that it is worth a little code rework to get all these great new features! Scriptom 1.2 is the version that is documented in Groovy in Action.

  • Provides simplified helper methods for dealing with COM apartment threading models.
  • ActiveXProxy name changed to ActiveXObject to match WSH convention.
  • VariantProxy no longer exists (the functionality was refactored into ActiveXObject).
  • Variant values are converted to and from the equivalent Java type; no more calling .value on everything!
  • Supports COM event callbacks using closures (this is still a work in progress, but usable as is).
  • Supports indexed properties, including multiple indexes.
  • Supports typed, multi-dimensional SafeArrays.
  • Supports pass-byref (in/out) values, both in method calls and event handler callbacks.
  • Supports COM enumerable types (so you can use .each, for example).
  • Supports missing arguments (for optional parameters) in method/property calls and events.
  • Includes constant definitions for several popular Windows applications, derived from these type libraries (see JavaDoc):
    • Microsoft Office 2003 (works with other versions as well)
      • Word 2003
      • Excel 2003
      • Outlook 2003
      • Access 2003
      • PowerPoint 2003
    • Microsoft Internet Explorer 6 (works with other versions as well)
    • Microsoft Scripting (i.e., FileSystemObject)
    • Microsoft Speech API
    • Windows Scripting Host (WSH)
    • WbemScripting (WMI - Windows Management Instrumentation)
  • Supports the latest features from Jacob 1.14, including new support for the Decimal data type and 64-bit integers.

Migrating from Previous Versions of Scriptom

Scriptom 1.5 is not backward compatible with previous versions of Scriptom.  To get your scripts running again, do this:

  • Change all references to ActiveXProxy into ActiveXObject.
  • Wrap any code that references an ActiveXObject in Scriptom.inApartment { ... }, which replaces the way Scriptom previously handled COM threading.  
  • Remove all references to .value property references. 
  • Remove any statically typed references to VariantProxy.
  • Support for COM events is greatly improved in this version - and also greatly changed.  Refer to the Events section below for more information.

Quick Start

Let's say you want an application that talks. Pure Java implementations aside (this is, after all, a Groovy/COM tutorial), and ignoring the fact that the default voice on pre-Vista machines sounds like Dr. Zoidberg with a sinus infection, you could use the Microsoft Speech API (SAPI) to get the job done.

You start by creating an ActiveXObject with the prog-id for SpVoice. Now you can call any of the methods it supports. By default, SpVoice will block until it is done speaking, but we're also going to have it speak asynchronously and wait until it is done.

If you have scripted COM before, you are probably used to using "magic numbers" throughout your code in place of COM constants.  In this code sample, we're using fully-qualified constants instead.

Scriptom includes fully JavaDoc'd constant and interface definitions from a number of commonly used type-libraries, and you can even create your own.  The source code for generating COM type library definitions for Groovy is written in Groovy(smile) , and it's included in the project. It may not seem like a big deal to replace a couple of numbers, but it will be a lot easier in 10 years to find relevant information on SpeechVoiceSpeakFlags.SVSFlagsAsync than on the number 1 (Google returns a little more than 9 billion hits for the number '1', and about 1,000 for 'SpeechVoiceSpeakFlags.SVSFlagsAsync,' including hits on this paragraph).  And besides, the code reads better.

Speaking of interfaces, it turns out that SpVoice supports several.  You can test an ActiveXObject to see if it supports a given interface using .supportsInterface, and you can cast an ActiveXObject to a given interface using .toInterface

This next example displays the COM interfaces that SpVoice supports (within the SAPI library only):

Programmer's Guide 

The Least You Need to Know about COM

how not to crash the JVM or lock your process

COM Data Types in Scriptom

supported types and conversions in Java, VB6, and VB.NET

COM Methods and Properties in Scriptom

calling COM methods and properties from Groovy

Passing Values by Reference (in-out)

how to let methods change the value of passed-in arguments

COM Events

support for COM events

All About Arrays



Here is a simple example that uses the Microsoft ScriptControl to evaluate a JScript expression.   This is a very indirect way to add 2 and 2.

There are many, many potential uses for Scriptom - far to many to try to maintain as part of this documentation.   So we've included a whole slew of meaty examples in the project archive for you to play with.  We'd like to encourage you to go look at those examples, run them, and modify them.  And if you come up with an especially interesting example, let us know about it.  We may even include it in a future release! 

Some additional examples included with Scriptom:

  • Automated writing to and reading from Excel spreadsheets. Includes COM events example.
  • Navigation in Internet Explorer.  Includes COM events example. 
  • Gathering information about processes and Windows NT services using WMI.
  • Parsing a *.msg file with Microsoft Outlook.

Consuming Visual Basic 6 (VB6) and Visual Basic.NET COM-enabled DLLs.


Articles about COM scripting in general, and Scriptom in particular.

Getting Started with COM

January 11, 2008

Tips for exploring COM libraries, finding documentation, etc.

Bridging the Gap Between Java and .NET with Groovy and Scriptom

December 3, 2007

Implement FIPS 140-1 compliant SHA-1 in Java with Groovy, Scriptom, and Visual Basic.NET.

Juixe TechKnow

August 8, 2006

A short Microsoft Outlook example.


March 17th, 2008

Siebel "business component" programming

Post Scriptom

All known (unresolved) issues and feature requests are listed in the Scriptom Jira database.

Changes to each build are summarized in the Change Log.

Recent builds of Scriptom can be found here. Older versions are archived:

Build 10. Bundled with the Groovy 1.5 Windows Installer. Requires Groovy 1.5 and Java 5 or better.

Scriptom 1.2

(also Scriptom 1.1 and Scriptom 1.0) Original version, and the one that is documented in Groovy in Action. Requires Groovy 1.0 or better and Java 1.4 or better.


Scriptom uses late binding. Visual Basic and VBA uses early binding by default, but they also support late binding (with CreateObject). If you are translating working Visual Basic code and if your Scriptom code fails at the point where you've got your call

 (or whatever your object is) with an error message

 then the chances are the progid "Sage...." that you are using is the wrong one.

So you need to go and look in the registry to find what it might be. One way to do this is with Microsoft's new Powershell cmd utility which you can download from the ms web site. Install this and run the command line

It will produce a ream of different progids which you can sort and search for one that looks a likely candidate. In my case it was SDOEngine.14

Alternatively if you have used the scriptom utility ExtractTlbInfo.groovy to generate name maps for the com object you could read the source code for the (in my case class and you might find some code and/or comment like this:

Additionally, you can use the Object Browser included with Visual Basic (I recommend the one with VBA) to figure out possible progids and then search the registry.  This is a good way to associate interfaces (and their methods) with a particular progid.  If there are VBScript or JScript examples available, they will include the correct progids, since these languages are always late-bound.

If all else fails, hit the Groovy mailing lists.  There are lots of people out there with COM experience who can point you in the right direction.

  • No labels