Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Gunakan metode dan properti objek SWbemObjectPath untuk membangun dan memvalidasi jalur objek. Objek ini dapat dibuat oleh panggilan VBScript CreateObject .
Anggota
Objek SWbemObjectPath memiliki jenis anggota ini:
Metode
Objek SWbemObjectPath memiliki metode ini.
| Metode | Deskripsi |
|---|---|
| SetAsClass | Memaksa jalur untuk mengatasi kelas WMI. |
| SetAsSingleton | Memaksa jalur untuk mengatasi instans WMI singleton. |
Properti
Objek SWbemObjectPath memiliki properti ini.
| Properti | Jenis akses | Deskripsi |
|---|---|---|
|
Otoritas |
Baca/Tulis |
String yang mendefinisikan komponen Otoritas dari jalur objek. |
|
Kelas |
Baca/Tulis |
Nama kelas yang merupakan bagian dari jalur objek. |
|
DisplayName |
Baca/Tulis |
String yang berisi jalur dalam formulir yang dapat digunakan sebagai nama tampilan moniker. Lihat Membuat Aplikasi atau Skrip WMI. |
|
IsClass |
Baca-saja |
Nilai Boolean yang menunjukkan apakah jalur ini mewakili kelas. Ini dianalogikan dengan properti __Genus di COM API. |
|
IsSingleton |
Baca-saja |
Nilai Boolean yang menunjukkan apakah jalur ini mewakili instans singleton. |
|
Kunci |
Baca-saja |
Objek SWbemNamedValueSet yang berisi pengikatan nilai kunci. |
|
Lokal |
Baca/Tulis |
String yang berisi lokal untuk jalur objek ini. |
|
Namespace |
Baca/Tulis |
Nama namespace layanan yang merupakan bagian dari jalur objek. Ini sama dengan properti __Namespace di COM API. |
|
ParentNamespace |
Baca-saja |
Nama induk namespace layanan yang merupakan bagian dari jalur objek. |
|
Jalur |
Baca/Tulis |
Berisi jalur absolut. Ini sama dengan properti sistem __Path di COM API. Ini adalah properti default objek ini. |
|
Relpath |
Baca/Tulis |
Berisi jalur relatif. Ini sama dengan properti sistem __Relpath di COM API. |
|
Keamanan_ |
Baca-saja |
Digunakan untuk membaca atau mengubah pengaturan keamanan. |
|
Server |
Baca/Tulis |
Nama server. Ini sama dengan properti sistem __Server di COM API. |
Contoh
Sampel kode VBScript berikut menunjukkan cara membangun jalur objek.
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 ""
Sampel kode Perl berikut menunjukkan cara membangun jalur objek.
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";
}
Persyaratan
| Persyaratan | Nilai |
|---|---|
| Klien minimum yang didukung |
Windows Vista |
| Server minimum yang didukung |
Windows Server 2008 |
| Header |
|
| Pustaka jenis |
|
| DLL |
|
| CLSID |
CLSID_SWbemObjectPath |
| IID |
IID_ISWbemObjectPath |