Session.Timeout 屬性

設定並取得用戶端應用程式等候 Windows 遠端系統管理完成其作業的時間上限,以毫秒為單位。

這是可讀寫的屬性。

Syntax

Session.Timeout As long

屬性值

逾時值,以毫秒為單位。 超過逾時值時,就會發生執行階段錯誤。

備註

在代理程式執行的每個作業之前,可以設定逾時值。 如果未指定逾時值,代理程式會設定逾時值。

在列舉作業期間,在列舉資源時,無法重設逾時值。

範例

下列 VBScript 程式碼範例會使用 WMI Win32_Process類別的Create方法啟動Calc.exe程式。 strInputParameters參數包含 XML 格式的輸入參數。 腳本會指定會話逾時。

Set objWsman = CreateObject( "WSMan.Automation" )
If objWsman is Nothing Then
    WScript.Echo "Failed to create WSMAN Automation object"
    WScript.Quit
End If 

Set objSession = objWsman.CreateSession
If objSession is Nothing Then
    WScript.Echo "Failed to create WSMAN Session object"
    WScript.Quit
End If 

strResource = "http://schemas.microsoft.com/wbem/wsman/1/" & _
    "wmi/root/cimv2/Win32_Process"

'Reset timeout to 10,000 milliseconds
objSession.Timeout = 10000     

strInputParameters = "<p:Create_INPUT " & _
    "xmlns:p=""http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process"">" & _
    "<p:CommandLine>" & "calc.exe" & _
    "</p:CommandLine>" & _
    "</p:Create_INPUT>"

strOutputParameters = objSession.Invoke( "Create", _
    strResource, strInputParameters )

DisplayOutput( strOutputParameters )

'****************************************************
' Displays WinRM XML message using built-in XSL
'****************************************************
Sub DisplayOutput( strWinRMXml )
    Dim xmlFile, xslFile
    Set xmlFile = CreateObject( "MSXml2.DOMDocument.3.0" ) 
    Set xslFile = CreateObject( "MSXml2.DOMDocument.3.0" )
    xmlFile.LoadXml( strWinRMXml )
    xslFile.Load( "WsmTxt.xsl" )
    Wscript.Echo xmlFile.TransformNode( xslFile ) 
End Sub

規格需求

需求
最低支援的用戶端
Windows Vista
最低支援的伺服器
Windows Server 2008
標頭
WSManDisp.h
Idl
WSManDisp.idl
程式庫
WSManDisp.tlb
DLL
WSMAuto.dll

另請參閱

工作階段