BT

Using Windows PowerShell from VBScript, JScript

by Abel Avram on Jul 29, 2008 |

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"
Else
     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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT