Revision: 15097
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 24, 2009 05:48 by vinocui
Initial Code
#!/usr/bin/perl -w # use bin\perl.exe wmi.pl to run. # have fun! # 2009/6/17 twitter.com/vinocui # # useful links: # (WMI space definition) http://msdn.microsoft.com/en-us/library/aa394084(VS.85).aspx # (OLE usage on CPAN) http://cpan.uwinnipeg.ca/htdocs/Win32-OLE/Win32/OLE.html#Object_methods_and_properties # use Win32::OLE; #my $wmi = Win32::OLE->GetObject("winmgmts://./root/cimv2") or die "failed to retrieve cimv2."; # winmgmts means to access WMI service. my $wmi = Win32::OLE->GetObject("WinMgmts://./root/cimv2") or die "Failed: GetObject\n"; my $list, my $v; # http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx # Minimum supported client Windows 2000 Professional # Minimum supported server Windows 2000 Server $list = $wmi->InstancesOf("Win32_Processor") or die "Failed: InstancesOf\n"; foreach $v (Win32::OLE::in $list){ print "CPU:\n"; print "\t", $v->{Name}, "\n"; print "\t", $v->{Caption}, "\n"; } # http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx # Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: # If a computer has multiple operating systems installed, this class only returns an # instance for the currently active operating system. $list = $wmi->InstancesOf("Win32_OperatingSystem") or die "Failed: InstancesOf\n"; foreach $v (Win32::OLE::in $list){ print "OS:\n"; print "\t", $v->{Name}, "\n"; } # http://msdn.microsoft.com/en-us/library/aa394512(VS.85).aspx # Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This class is supported. $list = $wmi->InstancesOf("Win32_VideoController") or die "Failed: InstancesOf\n"; foreach $v (Win32::OLE::in $list){ print "Video Memory:\n"; print "\t", $v->{Description}, "\n"; print "\t", $v->{AdapterRAM}/1024/1024, "MBytes \n"; } 0;
Initial URL
Initial Description
Refer to http://msdn.microsoft.com/en-us/library/aa394512(VS.85).aspx
Initial Title
(Perl) using WMI to get video memory information
Initial Tags
video
Initial Language
Perl