勇芳软件工作室.汉化:  Windows Management Instrumentation > Scripting API for WMI > Scripting API Objects > SWbemObjectPath >

Namespace Property

Previous pageReturn to chapter overviewNext page

描述

 

SWbemObjectPath对象的命名空间属性包含作为对象路径一部分的命名空间的名称。例如,以下路径显示返回root \\ cimv2的命名空间属性:

 

\\computer\root\cimv2:win32_logicaldisk="a:"

 

PowerBASIC 语法

 

PROPERTY GET Namespace () AS WSTRING

PROPERTY SET Namespace (BYVAL strNamespace AS WSTRING)

 

参数(仅限集属性)

 

strNamespace

 

BSTR.作为对象路径一部分的命名空间的名称。

 

返回值(仅获取资源)

 

BSTR.命名空间的名称。

 

示例代码

 

以下示例显示如何从作为硬盘的Win32_LogicalDisk的实例获取命名空间名称。脚本连接到默认命名空间。

 

Const HARD_DISK = 3

strComputer =“。”

设置objWMIService = GetObject(“winmgmts:”_

 &“{impersonationLevel = impersonate}!\\\\”&strComputer)

 

设置colDisks = objWMIService.ExecQuery _

 (“从Win32_LogicalDisk选择*”_

 &“其中DriveType =”&HARD_DISK &“”)

对于colDisks中的每个objDisk

 Set objpath = objDisk.path_

 Wscript.Echo“Win32_Logical磁盘实例的路径”_

 &objDisk.DeviceID &“=”&objpath.Namespace  

下一个

 

要求

 

客户

需要Windows Vista,Windows XP,Windows 2000 Professional,Windows NT Workstation 4.0 SP4及更高版本,Windows Me,Windows 98或Windows 95 OSR2及更高版本。

服务器

需要Windows Server 2008,Windows Server 2003,Windows 2000 Server或Windows NT Server 4.0 SP4及更高版本。

类型库

使用Wbemdisp.tlb。

Wbemdisp.inc。

DLL

需要Wbemdisp.dll。