Oggetto SWbemObjectPath

Usare i metodi e le proprietà dell'oggetto SWbemObjectPath per costruire e convalidare un percorso oggetto. Questo oggetto può essere creato dalla chiamata CreateObject VBScript.

Membri

L'oggetto SWbemObjectPath include questi tipi di membri:

Metodi

L'oggetto SWbemObjectPath dispone di questi metodi.

Metodo Descrizione
SetAsClass Forza il percorso per affrontare una classe WMI.
SetAsSingleton Forza il percorso per affrontare un'istanza WMI singleton.

Proprietà

L'oggetto SWbemObjectPath ha queste proprietà.

Proprietà Tipo di accesso Descrizione
Authority
Lettura/Scrittura
Stringa che definisce il componente Autorità del percorso dell'oggetto.
Classe
Lettura/Scrittura
Nome della classe che fa parte del percorso dell'oggetto.
DisplayName
Lettura/Scrittura
Stringa che contiene il percorso in un modulo che può essere usato come nome visualizzato moniker. Vedere Creazione di un'applicazione WMI o uno script.
IsClass
Sola lettura
Valore booleano che indica se questo percorso rappresenta una classe. Analogamente alla proprietà __Genus nell'API COM.
IsSingleton
Sola lettura
Valore booleano che indica se questo percorso rappresenta un'istanza singleton.
Chiavi
Sola lettura
Oggetto SWbemNamedValueSet contenente le associazioni di valori chiave.
Impostazioni internazionali
Lettura/Scrittura
Stringa contenente le impostazioni locali per questo percorso dell'oggetto.
Namespace
Lettura/Scrittura
Nome dello spazio dei nomi che fa parte del percorso dell'oggetto. Si tratta dello stesso valore della proprietà __Namespace nell'API COM.
ParentNamespace
Sola lettura
Nome dell'elemento padre dello spazio dei nomi che fa parte del percorso dell'oggetto.
Percorso
Lettura/Scrittura
Contiene il percorso assoluto. Si tratta dello stesso valore della proprietà di sistema __Path nell'API COM. Si tratta della proprietà predefinita di questo oggetto.
Relpath
Lettura/Scrittura
Contiene il percorso relativo. Si tratta dello stesso valore della proprietà di sistema __Relpath nell'API COM.
Sicurezza_
Sola lettura
Usato per leggere o modificare le impostazioni di sicurezza.
Server
Lettura/Scrittura
Nome del server. Si tratta dello stesso valore della proprietà di sistema __Server nell'API COM.

Esempio

L'esempio di codice VBScript seguente illustra come compilare i percorsi degli oggetti.

on error resume next 
Set ObjectPath = CreateObject("WbemScripting.SWbemObjectPath")
ObjectPath.Server = "dingle"
ObjectPath.Namespace = "root/default/something"
ObjectPath.Class = "ho"
ObjectPath.Keys.Add "fred1", 10
ObjectPath.Keys.Add "fred2", -34
ObjectPath.Keys.Add "fred3", 65234654
ObjectPath.Keys.Add "fred4", "Wahaay"
ObjectPath.Keys.Add "fred5", -786186777

if err <> 0 then 
 WScript.Echo err.number
end if 

WScript.Echo "Pass 1:"
WScript.Echo ObjectPath.Path
WScript.Echo ObjectPath.DisplayName
WScript.Echo ""

ObjectPath.Security_.ImpersonationLevel = 3

WScript.Echo "Pass 2:"
WScript.Echo ObjectPath.Path
WScript.Echo ObjectPath.DisplayName
WScript.Echo ""

ObjectPath.Security_.AuthenticationLevel = 5

WScript.Echo "Pass 3:"
WScript.Echo ObjectPath.Path
WScript.Echo ObjectPath.DisplayName
WScript.Echo ""

Set Privileges = ObjectPath.Security_.Privileges
if err <> 0 then
 WScript.Echo Hex(Err.Number), Err.Description
end if
Privileges.Add 8
Privileges.Add 20, false

WScript.Echo "Pass 4:"
WScript.Echo ObjectPath.Path
WScript.Echo ObjectPath.DisplayName
WScript.Echo ""

ObjectPath.DisplayName = "winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktprivacy,(Debug,!IncreaseQuota, CreatePagefile ) }!//fred/root/blah"

WScript.Echo "Pass 5:"
WScript.Echo ObjectPath.Path
WScript.Echo ObjectPath.DisplayName
WScript.Echo ""

L'esempio di codice Perl seguente illustra come compilare i percorsi degli oggetti.

use strict;
use Win32::OLE;
use constant FALSE=>"false";

my ( $ObjectPath, $Privileges );

eval { $ObjectPath = new Win32::OLE 'WbemScripting.SWbemObjectPath'; };
unless($@)
{
 eval
 {
  $ObjectPath->{Server} = "dingle";
  $ObjectPath->{Namespace} = "root/default/something";
  $ObjectPath->{Class} = "ho";
  $ObjectPath->{Keys}->Add("fred1", 10);
  $ObjectPath->{Keys}->Add("fred2", -34);
  $ObjectPath->{Keys}->Add("fred3", 65234654);
  $ObjectPath->{Keys}->Add("fred4", "Wahaay");
  $ObjectPath->{Keys}->Add("fred5", -786186777);
 };
 unless($@)
 {
  print "\n";
  print "Pass 1:\n";
  print $ObjectPath->{Path}, "\n";
  print $ObjectPath->{DisplayName} , "\n\n";

  $ObjectPath->{Security_}->{ImpersonationLevel} = 3 ;

  print "Pass 2:\n";
  print $ObjectPath->{Path}, "\n";
  print $ObjectPath->{DisplayName} , "\n\n";

  $ObjectPath->{Security_}->{AuthenticationLevel} = 5 ;

  print "Pass 3:\n";
  print $ObjectPath->{Path}, "\n";
  print $ObjectPath->{DisplayName} , "\n\n";

  eval { $Privileges = $ObjectPath->{Security_}->{Privileges}; };
  unless($@)
  {
   $Privileges->Add(8);
   $Privileges->Add(20,FALSE);

   print "Pass 4:\n";
   print $ObjectPath->{Path}, "\n";
   print $ObjectPath->{DisplayName} , "\n\n";

   $ObjectPath->{DisplayName} = "winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktprivacy,(Debug,!IncreaseQuota, CreatePagefile ) }!//fred/root/blah";

   print "Pass 5:\n";
   print $ObjectPath->{Path}, "\n";
   print $ObjectPath->{DisplayName} , "\n";
  }
  else
  {
   print STDERR Win32::OLE->LastError, "\n";
  }
 }
 else
 {
  print STDERR Win32::OLE->LastError, "\n";
 }
}
else
{
 print STDERR Win32::OLE->LastError, "\n";
}

Requisiti

Requisito Valore
Client minimo supportato
Windows Vista
Server minimo supportato
Windows Server 2008
Intestazione
Wbemdisp.h
Libreria dei tipi
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemObjectPath
IID
IID_ISWbemObjectPath

Vedi anche

Scripting di oggetti API