Session.Put 메서드

리소스를 업데이트합니다.

구문

Session.Put( _
  ByVal resourceUri, _
  ByVal resource, _
  [ ByVal flags ] _
)

매개 변수

resourceUri [in]

업데이트할 리소스의 식별자입니다.

이 매개 변수는 다음 목록에 포함된 요소 중 하나를 포함할 수 있습니다.

  • 선택기가 있거나 없는 URI입니다. Put 메서드를 호출하여 WMI 리소스를 가져올 때 개체의 키 속성 또는 속성을 사용합니다. 예를 들어 다음 VBScript(Visual Basic Scripting Edition) 코드 예제에서 키는 로 Win32_Service?Name=winmgmt지정됩니다.

    strResourceUri = "http://schemas.microsoft.com/" & _ 
      "wbem/wsman/1/wmi/root/cimv2/Win32_Service?Name=winmgmt"
    
  • 선택기, 조각 또는 옵션을 포함할 수 있는 ResourceLocator 개체입니다.

  • WS-Management Protocol 표준에 설명된 WS-Addressing 엔드포인트 참조입니다. WS-Management 프로토콜에 대한 공용 사양에 대한 자세한 내용은 관리 사양 인덱스 페이지를 참조하세요.

리소스 [in]

업데이트된 리소스 콘텐츠입니다.

flags [in, optional]

예약되어 있습니다. 0으로 설정해야 합니다.

반환 값

업데이트된 리소스 콘텐츠가 포함된 XML입니다.

예제

다음 VBScript 코드 예제에서는 Win32_WMISetting 개체에 데이터를 씁니다. 리소스 매개 변수의 XML에 개체의 모든 비 배열 속성을 포함해야 합니다. 속성의 순서는 중요하지 않습니다.


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

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

'Change the property value by putting
'the new XML content into the resource.
Dim strResourceUri, strReturnedResourceUri, newXmlContent
strResourceUri = "http://schemas.microsoft.com/wbem/wsman/1/" _
  & "wmi/root/cimv2/Win32_WMISetting"
newXmlContent = _
  "<p:Win32_WMISetting xmlns:p=""http://schemas.microsoft.com/" & _
  "wbem/wsman/1/wmi/root/cimv2/Win32_WMISetting"">" & _
  "<p:LoggingLevel>2</p:LoggingLevel></p:Win32_WMISetting>" 

On Error Resume Next
strReturnedResourceUri = objSession.Put(reourceUri, newXmlContent)
WScript.Echo "Returned resource Uri:" & Chr(10) & _
  strReturnedResourceUri
If Err.Number <> 0 Then
    DisplayErrorInfo
End If
On Error Goto 0

Sub DisplayErrorInfo()
    WScript.Echo "An error has occurred."     
    WScript.Echo
    WScript.Echo "Error Info"
    WScript.Echo "-----------"
    WScript.Echo "Number      : 0x" & hex(Err.number)
    WScript.Echo "Description : " & Err.Description
    WScript.Echo "Source      : " & Err.Source
    WScript.Echo "HelpFile    : " & Err.helpfile
    WScript.Echo "HelpContext : " & Err.HelpContext    
    WScript.Echo Err.Clear    
End Sub

요구 사항

요구 사항
지원되는 최소 클라이언트
Windows Vista
지원되는 최소 서버
Windows Server 2008
헤더
WSManDisp.h
IDL
WSManDisp.idl
라이브러리
WSManDisp.tlb
DLL
WSMAuto.dll

추가 정보

세션