pragma namespace

The pragma namespace preprocessor command requests that the compiler load the MOF file into the namespace specified as namespacepath. If both the MOF compiler -n namespace switch and the #pragma namespace namespacepath command are used, the command takes priority over the switch.

The following describes the syntax:

#pragma namespace ("[Namespace]")

[Namespace] is the specified namespace.

If you do not specify this command or the equivalent command-line switch, the MOF compiler uses the root\default namespace by default.


You can require that client scripts and applications use an encrypted connection for authentication by adding the RequiresEncryption qualifier to the .mof file that creates the namespace. You can also modify an existing namespace by adding this attribute and compile the MOF file again. For more information about how to use RequiresEncryption, see Requiring an Encrypted Connection to a Namespace.


The following example shows how place classes or instances in the "Root\Test" namespace.

#pragma namespace ("\\\\.\\Root\\Test")


Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008

See also

Setting Namepace Security Descriptors

Standard WMI Qualifiers

Preprocessor Commands