Subject Re: Accessing Computer Serial Number
From <rich@autotraker.com> <<rich@autotraker.com>>
Date Fri, 15 Feb 2019 09:51:00 -0500
Newsgroups dbase.getting-started

Not sure what you are looking for or trying to do.
You want the BIOS serial number?
WMIC BIOS get serialnumber, returns the BIOS serial number which might not
be unique or exist depending on the manufacturer of the BIOS.
Or maybe the Motherboards serial number would be better?
Or maybe the Operating System serial number?
There is no guarantee any machine with have any of these or that they aren't
duplicated on numerous machines.
In other words, your machine may not even have any of these serial numbers
and it may not be unique.
And its not necessary to run a DOS command and read a text file for the
result.

   objLocator = new OleAutoClient("WbemScripting.SWbemLocator")
   objWMI=objLocator.ConnectServer(".", "root\cimv2")
   objWMI.Security_.ImpersonationLevel=3 // Impersonate

   oItems = objWMI.ExecQuery( [select * from Win32_BaseBoard] )
    ? oItems[0].SerialNumber

    oItems = objWMI.ExecQuery( [select * from Win32_BIOS] )
    ? oItems[0].SerialNumber

    oItems = objWMI.ExecQuery( [select * from Win32_OperatingSystem] )
    ? oItems[0].SerialNumber

   release oItems
   release object objWMI
   release object objLocator



In the binaries group you'll find my serialNumbers.cc
That will generate a unique serial number based on several different serial
numbers.
So far in in a couple thousand machines tested getUniqueSerialNumber2() so
far seems to generate a unique serial number even on clone machines.
Also serialNumbers.cc has a few more serial numbers you may find useful

To get the "Hostname" which is the computer name try this
? getEnv("ComputerName")
You can grab any of environmental variables this way...

Rich...




"Matt Milner"  wrote in message news:5Azy#BTxUHA.700@ip-AC1E04A7...

I am writing a security interface to my software. As part of this process, I
lock to the computer's serial number.  To get the serial number, I type
this: Run( "WMIC BIOS get serialnumber > serialnumber.txt").  This creates a
text file containing the serial number. I then open a database and type
this: append from serialnumber.txt sdf
When I do this  I get this error:  Database Engine Error: Corrupt file -
other than header.  Is there another way to get the serial number? To
contrast, when I get the hostname by typing Run("hostname > hostname.txt")
the data appends just fine.