PowerShell Memo

このサイトはPowerShell(MSH/Monad)奮闘記です

管理人「newpops吉岡洋」が
「PowerShell(旧名:MSH/Monad)」の研究結果を日々綴っていきます。

【お知らせ】
この日記からPowerShellのTipsを抽出し「PowerShell FAQ」として整理しました。


2006-01-08

[][]Use of IronPython in Monad

STEP1 Install of IronPython 1.0 Beta1

Last month IronPython 1.0 Beta was released.

http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742


The install of IronPython is very easy.

1. Download IronPython 1.0 Beta1 from Here

2. Files created by decompression of [IronPython-1.0-Beta1.zip] put your favorite folder.

STEP2 Call IronPython in Monad

1.

Load IronPython.dll.

ex)

[void][Reflection.Assembly]::LoadFrom("C:\IronPython\IronPython.dll")

2.

Create ScriptEngine Object of IronPython by new-object Cmdlet.

ex)

$pe = new-object ironpython.hosting.pythonengine

3.

Call Execute method.

ex)

$code="print 'Hello IronPython'"

$pe.Execute($code)

IronPython Sample

GUI Sample
[void] [Reflection.Assembly]::LoadFrom("C:\IronPython\IronPython.dll")
$pe = new-object ironpython.hosting.pythonengine

$code=@"
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import *
f = Form(Text="IronPython Sample")
f.ShowDialog()
"@

$pe.Execute($code)
Sample Result

Connection: close