Numero de serie de la placa base (BOARD)

171 views
Skip to first unread message

JORGE HERNANDEZ

unread,
Jul 8, 2023, 11:01:49 PM7/8/23
to Harbour Users
Cordial saludo. A todos.

¿Harbour tiene una instrucción para saber el numero de serie de la placa base (board).?

Gracias de antemano.

Atentamente,

JORGE EDUARDO.

Antonio Linares

unread,
Jul 9, 2023, 2:06:52 AM7/9/23
to Harbour Users
local oLoc := CreateObject ( "wbemScripting.SwbemLocator" )
local objWMI := oLoc:ConnectServer()
local oTipo_Board := objWMI:ExecQuery ( "Select Product, SerialNumber FROM Win32_BaseBoard" )

FOR EACH oDatos IN oTipo_Board
? "Tipo : " + ALLTRIM ( oDatos:Product ) + ;
", Serie: " + ALLTRIM ( oDatos:SerialNumber ) + CRLF
NEXT

kamleh patel

unread,
Jul 11, 2023, 9:05:04 AM7/11/23
to harbou...@googlegroups.com
Hello,
Only work in Admin User this function for getting a detailed motherboard serial no.
How to work as a normal user. 

Regards
Kamlesh

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/d8c38b86-78ba-4838-953f-bbf99a63ab45n%40googlegroups.com.

Bernard Mouille

unread,
Jul 11, 2023, 9:08:13 AM7/11/23
to Harbour Users
Hello  Kamlesh,
A code below my signature.
Regards,
Bernard.

// Begin code.
/*
   BH_GetBaseBoardSerialNumber.prg
   Get the base board serial number.
   Using HB32, Windows10

   Compile with -lhbwin

   This code is a basic sample for tests.

   https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-baseboard

   web : http://bernard.mouille.free.fr/mso-hb32/BH_GetBaseBoardSerialNumber.txt
   Last change : 2023-07-09
*/

procedure Main

   setmode( 25, 80 )
   setcolor( "GR+/B" )
   @ 0, 0, maxrow(), maxcol() box space( 9 )
   ? "Get the base board serial number."
   ?
   ? bh_GetBaseBoardSerialNumber()
   ?
   wait
   return

function bh_GetBaseBoardSerialNumber()

   local oLocator  // WbemScripting.SWbemLocator object.
   local oWMI      // WMI object.
   local oItem     // Item object.
   local aSys      // Base board array ( 1 element ).
   local cReturn   // Return serial number.

   oLocator := Win_OleCreateObject( "WbemScripting.SWbemLocator" )
   oWMI     := oLocator:ConnectServer( ".", "root\cimv2" )
   aSys     := oWMI:ExecQuery( 'Select * from Win32_BaseBoard' )

   cReturn := ""
   for each oItem in aSys
      cReturn  += oItem:SerialNumber
   endfor

   oItem    := nil
   aSys     := nil
   oWMI     := nil
   oLocator := nil

   return cReturn
// End code.

kamleh patel

unread,
Jul 11, 2023, 9:13:26 AM7/11/23
to harbou...@googlegroups.com
Sir,

Work in normal user Like User is not Administrator.

Regards
Kamlesh


kamleh patel

unread,
Jul 11, 2023, 9:21:29 AM7/11/23
to harbou...@googlegroups.com
Sir,

Code is compiled successfully.
Exe run but not any value display.
Regards
Kamlesh


On Tue, Jul 11, 2023 at 6:38 PM Bernard Mouille <bernardm...@gmail.com> wrote:

José M. C. Quintas

unread,
Jul 11, 2023, 9:45:33 AM7/11/23
to harbou...@googlegroups.com

Here ok.

Return is "To be filled by O.E.M."

On Microsoft site, about my Windows 10 installation, I see this text.

Now I know this text is my board serial number.


José M. C. Quintas

Jayadev U

unread,
Jul 11, 2023, 10:24:31 AM7/11/23
to harbou...@googlegroups.com

Hi Bernard,

 

Excellent function I must say.  Works correctly.

 

If the program is on a shared folder on a Server and is “run” on  node, it will report the motherboard serial number of the node correct ?.

Is there a function to get the motherboard serial number of the Server where the program resides ?

 

Warm regards,

 

Jayadev

Bernard Mouille

unread,
Jul 11, 2023, 10:56:39 AM7/11/23
to Harbour Users
Hello Yayadev,
I have not server but you can replace :
   oWMI     := oLocator:ConnectServer( ".", "root\cimv2" )
by
   oWMI     := oLocator:ConnectServer( "Server_Name", "root\cimv2" )
Maybe the security level will not good ?
Regards,
Bernard.

Auge & Ohr

unread,
Jul 11, 2023, 6:56:16 PM7/11/23
to Harbour Users
hi,

WMI must be "enable"
you need Admin Right for WMI

WMI report "Local" Settings and must run "on" Local PC
you also can use it to get "remote" PC Information

---

SerialNumber FROM Win32_BaseBoard are not a good Way to "identfy" a PC
SerialNumber FROM Win32_DiskDrive, which is NOT "Volumeseriennummer", can be change

i recommend tu use Win32_NetworkAdapterConfiguration
MACAddress   FROM Win32_NetworkAdapterConfiguration

the Network Chip is "on-Board" and MACAddress is Unique

Jimmy

Bernard Mouille

unread,
Jul 12, 2023, 5:51:59 AM7/12/23
to Harbour Users
Hello,
I try with CMD but the user must to be an admin account.
Regards,
Bernard.

// Begin code.
/*
   BH_GetBaseBoardSerialNumber.prg
   Get the base board serial number.
   Using HB32, Windows10

   Compile with -lhbwin

   *** The user must to be an admin account. ***
   Last change : 2023-07-12

*/

procedure Main

   setmode( 25, 80 )
   setcolor( "GR+/B" )
   @ 0, 0, maxrow(), maxcol() box space( 9 )
   ? "Get the base board serial number."
   ?
   ? "WMI :", bh_GetBaseBoardSerialNumber()
   ? "CMD :", bh_GetBaseBoardSerialNumberCMD()

   ?
   wait
   return

function bh_GetBaseBoardSerialNumber()
   local oLocator  // WbemScripting.SWbemLocator object.
   local oWMI      // WMI object.
   local oItem     // Item object.
   local aSys      // Base board array ( 1 element ).
   local cReturn   // Return serial number.
   oLocator := Win_OleCreateObject( "WbemScripting.SWbemLocator" )
   oWMI     := oLocator:ConnectServer( ".", "root\cimv2" )
   aSys     := oWMI:ExecQuery( 'Select * from Win32_BaseBoard' )
   cReturn := ""
   for each oItem in aSys
      cReturn  += oItem:SerialNumber
   endfor
   oItem    := nil
   aSys     := nil
   oWMI     := nil
   oLocator := nil
   return cReturn

function bh_GetBaseBoardSerialNumberCMD()
   local cReturn := ""
   with object win_oleCreateObject( "WScript.Shell" ):Exec( 'cmd /K wmic baseboard get serialnumber &exit' )
      :StdOut:ReadLine()
      cReturn += :StdOut:ReadLine()
   end with
   return cReturn
// End code.
Reply all
Reply to author
Forward
0 new messages