"Jason shaw" <[EMAIL PROTECTED]> writes:

> 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.

You mean for the same user logging into the same machine, sometimes it
works and sometimes it doesn't?  Or it works for some users but not
others, or on some machines but not others?

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

Your code is not how I would write it, exactly :-), but it looks fine.

One thing I always add to my WMI scripts is this:

  # Bomb out completely if COM engine encounters any trouble.
  Win32::OLE->Option ('Warn' => 3);

This will cause the script to die() with an informative message if any
OLE call signals an error.  Assuming you can monitor stderr from your
logon script, this might be informative.

When I was doing something similar, I found that different systems
store their serial numbers in different places.  Usually the
SerialNumber field of Win32_BIOS had it, but sometimes that was
undefined (or whitespace; I do not remember exactly).

My final algorithm for obtaining the serial number was:

  1) Set $serial SerialNumber from Win32_BIOS object

  2) If $serial is undefined or whitespace, set it to the SerialNumber
     field of the Win32_SystemEnclosure object

  3) If $serial is still undefined or whitespace, set it to the
     SMBIOSAssetTag field of the Win32_SystemEnclosure object

But it sounds like your problem is more fundamental.

You do know you can use WMI to query this information remotely?

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

Reply via email to