This peace of code helps you retrieves all the namespaces that are on your pc.
All the namespaces are printed to the screen and are stored in the array @nameSpaces.
(Note that the stored namespaces are using a single backslash, which should be replaced by a double backslash in order to connect to it.)
The code works for me and I tested it on Windows XP SP2.
(Thanks to the Microsoft Scripting Guys for providing the vb code).
#!/usr/local/perl
use Win32::OLE('in');
use strict;
# Variables
my $stepOk = 1;
my $errorMsg = "";
my $wmiService = "";
my $computer = "."; # Computer to connect to: . = local host
my @nameSpaces = ();
enumNameSpaces("root");
sub enumNameSpaces
{
my $nameSpaceStr = shift;
print $nameSpaceStr."\n";
push(@nameSpaces,$nameSpaceStr);
$wmiService = Win32::OLE->GetObject("winmgmts:\\\\".$computer."\\".$
+nameSpaceStr);
($stepOk = 0) unless $wmiService;
if(! $stepOk)
{
$errorMsg = "Unable to open wmi services";
print $errorMsg."\n";
}
my $subDevices = $wmiService->InstancesOf("__NAMESPACE");
foreach my $subDevProp ( in( $subDevices ) )
{
enumNameSpaces($nameSpaceStr."\\".$subDevProp->{Name});
}
}
# Scripted by jschollen
# Thanks to the Microsoft Scripting Guys