Hello, I've wrote a script that records a computers hardware info (CPU, RAM, HD, etc) 
everytime a user logons via the logon script. I'm having problems getting the serial 
number of the machine that's stored in the BIOS through WMI. Sometimes it works, 
somtimes it doesn't. And it appears that it's not a user rights issue.

Is there a way that I'm suppose to initialize WMI before using it? Can anyone see 
what's wrong with my code?

Below is the code I'm using (I actually got 99% of the code I copied from another 
email on this list, sorry I don't know the name of the person that wrote it).

<CODE>
sub SerialNum()
{
    use strict;
    use Win32::OLE qw(in);

    my $SerialNo;  # The serial number

    # Getting the serial number
    my $WMI = Win32::OLE->GetObject("winmgmts://./root/cimv2");
    my @Results = in($WMI->ExecQuery("Select SerialNumber from Win32_BIOS"));
    
    # Setting the serial number
    $SerialNo = $Results[0]->{SerialNumber};

    # Returning serial number
    return $SerialNo;
}
</CODE>

Any help would be cool! Thanks!


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to