Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Using Windows PowerShell from VBScript, JScript

Using Windows PowerShell from VBScript, JScript

This item in japanese

Sapien Technologies has made available ActiveX PowerShell (ActiveXPosh), a free scripting tool which allows calling the Windows PowerShell from any COM compatible scripting language like VBScript or JScript. ActiveXPosh is useful to enhance existing scripts to make use of the PowerShell functionality.

Sapien describes ActiveXPosh as following:

A COM component that can be used from VBScript, JScript, KiXtart, or any other COM-compatible language. Allows you to create a direct Powershell host and use cmdlets and scripts from within your favorite scripting language. Multiple output options make integration flexible.

An example of using ActiveXPosh can be found in the description document provided by Sapien:

Set ActiveXPosh = CreateObject("SAPIEN.ActiveXPosh")
if ActiveXPosh.Eval("Get-Process Winword") = vbTrue Then
     WScript.Echo "Word is running"
     WScript.Echo "Word is NOT running"
End If

The tool's interface is made up from the following commands:

  • ClearOutput() - This method clears the internal output buffer.
  • Execute(strcommand) - Executes a PowerShell command or script.
  • Eval(strExpression) - Evaluates a PowerShell expression.
  • Init(execProfile) - Initial call to instantiate a PowerShell engine.
  • IsPowerShellInstalled - Returns True/False.
  • Output - A collection of strings filled with output from
    PowerShell commands.
  • OutputString - The content of the output buffer as a single string.
  • OutputMode - Sets or gets the current output mode.
  • OutputWidth - Sets or gets the desired output width.

ActiveXPosh is offered with other free scripting tools under the Free Tools Universal License Agreement.

Rate this Article