If your code is this simple....

use Win32::OLE qw (in);
my $WMIServices = Win32::OLE->GetObject("WinMgmts:") || die;
my $DriveCollection = $WMIServices->InstancesOf( "Win32_DiskDrive" );
if (Win32::OLE->LastError() != 0) {
  print Win32::OLE->LastError()."\n";
}
foreach $drive (in $DriveCollection) {
  print $drive->{Name}."\n";
}

On my system it works... And prints the following..

\\.\PHYSICALDRIVE0
\\.\PHYSICALDRIVE1
\\.\PHYSICALDRIVE2
\\.\PHYSICALDRIVE3

Steven 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Craig A Dayton
Sent: Monday, January 02, 2006 9:06 PM
To: Perl-Win32-Admin@listserv.ActiveState.com
Subject: Win32::OLE and WMI Invalid Syntax


Might there be an existing bug in Win32::OLE when attempting to create
an WMI Service object?  I'm running perl build 815 [211909] on WinXP Pro
w/SP2 and the latest patches.

The script will always fail on the first line regardless of the moniker
specified. Its running with administrator privileges.

my $WMIServices = Win32::OLE->GetObject("WinMgmts:") || die; my
$DriveCollection = $WMIServices->InstancesOf( "Win32_DiskDrive" );

The error message returned is: 

Win32::OLE(0.1703) error 0x800401e4: "Invalid syntax"
after character 0 in "WinMgmts:" at C:\Projects\WMI\WDiskDrives.pl line
99

Searching the email archives, I see a number of people experienced this
problem a few years back, but I didn't see any resolutions posted.

I'm able to access WMI using other tools such as WMI Object Brower, CIM
Studio, and wmic on the Win XP machine.  So, I think WMI is configured
correctly.

Has anyone else solved this problem?

Thanks, Craig

_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to