剖析 OutParameters 物件
系統會建立 SWbemMethod.OutParameters 物件,並由執行中的提供者方法提供數據。 OutParameters 物件的屬性專屬於所召喚的方法。 例如,在下列腳本中,SD(包含在 outParam 中)是針對 __SystemSecurity.GetSD 方法定義的輸出參數。 ReturnValue 屬性是適用於所有 OutParameters 物件的泛型屬性,其中包含作業的結果。
下列程式代碼範例說明如何在本機系統的 類別 __SystemSecurity 中執行 GetSD 方法,以取得輸出參數。
' Connect to WMI root\cimv2 namespace.
Set svc = GetObject("winmgmts:root/cimv2")
' Execute the GetSD method and obtain the output parameters.
set outParam = svc.Execmethod("__SystemSecurity=@", "GetSD")
wscript.echo outparam.ReturnValue
' Format the security descriptor array
' in the SD parameter into one string to display.
objSD = Join(outparam.SD,",")
wscript.echo objSD
' Release the out parameters object.
set outParam = nothing
如需詳細資訊,請參閱 SWbemMethod.InParameters。