Set s = GetObject("script:C:\script\ScriptControlX64.wsc")
s.Language = "VBScript"
s.AddCode "Sub addDictionary(dict, key, value): dict.Add key, value: End Sub"
Set dict = CreateObject("Scripting.Dictionary")
' AddObjectのパターン
s.AddObject "dict", dict
s.ExecuteStatement "addDictionary dict, ""key"", 111"
' CodeObjectのパターン
s.CodeObject.addDictionary dict, "key", 111
$s = [system.runtime.interopservices.marshal]::BindToMoniker("script:C:\script\ScriptControlX64.wsc")
$s | Get-Member
Name MemberType Definition
---- ---------- ----------
AddCode Method Variant AddCode (Variant, Variant)
AddObject Method Variant AddObject (Variant, Variant, Variant)
Eval Method Variant Eval (Variant, Variant)
ExecuteStatement Method Variant ExecuteStatement (Variant, Variant)
CodeObject Property Variant CodeObject () {get}
Language Property Variant Language () {get} {set}
$s.Language = "VBScript"
$s.AddCode("Function getTypeName(v): getTypeName = TypeName(v):End Function", $null)
$s.CodeObject | Get-Member
Name MemberType Definition
---- ---------- ----------
getTypeName Method Variant getTypeName (Variant)
$s.CodeObject.getTypeName((dir .\test.txt))
FileInfo