Query the XML of an MPF Namespace


var mpf, nsFound;

ConnectToWMI();
nsFound = FindMPFNamespace("Test Provider");
if (nsFound == null)
  ReportError("Namespace not found.");

function ReportError(desc)
{
  WScript.Echo(desc);
  WScript.Quit(-1);
}

function ConnectToWMI()
{
  // Connect to the MPF namespace.
  mpf = GetObject("WinMgmts:root/mpf");
}  

function FindMPFNamespace(nsName)
{
  var nsEnum;
  
  // Query for our namespace
  nsEnum = new Enumerator(mpf.ExecQuery(
	 "select * from MSFT_MPFNamespace " +
	 "where NamespaceName='" + nsName + "'"));
  if (nsEnum.atEnd())
	 return null;
	 return nsEnum.item();
}

// Get and display the XML. 
WScript.Echo(nsFound.GetXML());

See Also

MSDN® information on Windows Management Instrumentation (WMI) and Windows Script Host


Up Top of Page
© 1999-2002 Microsoft Corporation. All rights reserved.