Menu:

DotNet频道

在VBScript和JScript里使用Windows PowerShell

  

【InfoQ中文站】Sapien Technologies开发出了ActiveX PowerShell(ActiveXPosh)这是一个免费的脚本工具,用它可以在任何兼容COM的脚本语言里调用Windows PowerShell,比如VBScript和JScript。ActiveXPosh使我们可以利用PowerShell的功能增强现有的脚本。

Sapien是这样描述ActiveXPosh的:

可在VBScript、JScript、KiXtart或任何COM兼容的语言中使用这个COM组件。用它可在你喜欢的脚本语言中建立PowerShell宿主并使用cmdlet和PowerShell脚本。多样化的输出选项,可以让集成更灵活。

以下是Sapien在说明文档中提供的一个使用ActiveXPosh的例子:

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
该工具的接口由以下命令组成:

Article Provenance:futurelight  
Article Tags: