f8g

Windows スクリプト コンポーネント

を試す。

  1. Script Component Wizardを使ってwscファイルを作る。
<?xml version="1.0"?>
<component>

<?component error="true" debug="true"?>

<registration
	description="Test"
	progid="Test.WSC"
	version="1.00"
	classid="{00000000-0000-0000-0000-000000000000}"
>
</registration>

<public>
	<property name="TestP">
		<get/>
		<put/>
	</property>
	<method name="TestM">
	</method>
	<event name="TestE"/>
</public>

<implements type="Behavior" id="Behavior"/>

<script language="JScript">
<![CDATA[

var description = new Test;

function Test()
{
	this.get_TestP = get_TestP;
	this.put_TestP = put_TestP;

	this.TestM = TestM;
}

var TestP = 1;

function get_TestP()
{
	return TestP;
}

function put_TestP(newValue)
{
	TestP = newValue;
}

function TestM()
{
	return "Temporary Value";
}

]]>
</script>

</component>
  1. 登録する

>Regsvr32 test.wsc

  1. 使う
var test = WScript.CreateObject("Test.WSC");
WScript.Echo(test.TestP); // 1
WScript.Echo(test.TestM()); // Temporary Value

簡単。
Apolloなんて流行に乗らず、PerlPHPRubyも使えるWSCですよね。Microsoft死んでないよ。