Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 15, 2018 10:34 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Serial No of hardware
PostPosted: Mon Mar 11, 2013 4:30 am 
Offline

Joined: Wed Jan 11, 2006 1:13 pm
Posts: 57
Location: Münster, Germany
To give restricted access to one of my programs I use the MAC-Number to identify the computer.
Unfortunately this number changes when the user swaps between Wi-Fi and LAN.
It would be helpful when I could read out the serial number of the hardware (which should be stable), but I have no clue how to do so.
Thanks for any helpful information on this topic.

Bernhard


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 4:57 am 
Offline

Joined: Fri Aug 31, 2012 3:56 pm
Posts: 82
Use: SystemInformationMBS.MacUUID from http://www.monkeybreadsoftware.net/syst ... thod.shtml OR Shell.Exexute "system_profiler"


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 5:41 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Yes, please check our SystemInformationMBS module:

http://www.monkeybreadsoftware.net/modu ... nmbs.shtml

SystemInformationMBS.MACAddressString should always give first MAC ID.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 8:34 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
This works for OSX and WINDOWS..... NO PLUGINS REQUIRED


#If Not DebugBuild
#pragma DisableBackgroundTasks
#pragma DisableBoundsChecking
#pragma DisableAutoWaitCursor
#pragma StackOverflowchecking False
#pragma NilObjectChecking False
#EndIf
Dim sh As New Shell
Dim s As String
Dim x As Integer
If reg_key<>"" Then Return reg_key

#If TargetMacOS
//sh.execute "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"
sh.execute "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep ""Serial Number (system):"""
s=sh.Result
x=InStr(s,"=")
If x=0 Then x=InStr(s,":")
If x>0 Then s=ReplaceAll(Trim(Mid(s,x+1)),Chr(34),"")
#ElseIf TargetWin32
// use IPCONFIG /all and parse the "Physical Address from "Local Area Connection" Block
// will be something like C4-2C-03-02-31-26 [C42c03023126 take first 11 char = C42C0302312]
sh.Execute("ipconfig /all")
If sh.ErrorCode = 0 Then
s = sh.Result
s = Mid(s,InStr(s,"Local Area Connection")+21)
s = Mid(s,InStr(s,"Physical Address")+16)
s = Left(s,InStr(s,EndOfLine))
s= Left(ReplaceAll(Trim(Right(s,19)),"-","")+"Q9734WF",11)
End If
#EndIf
If s="" Then s="Z98888AAAQ2" ' could not get REAL value.. so use something bogus

Return s

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 12:55 pm 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
DaveS wrote:
#ElseIf TargetWin32
// use IPCONFIG /all and parse the "Physical Address from "Local Area Connection" Block
// will be something like C4-2C-03-02-31-26 [C42c03023126 take first 11 char = C42C0302312]
sh.Execute("ipconfig /all")


That returns the MAC address. How about something like this instead
#ElseIf TargetWin32
sh.Execute("wmic bios get serialnumber")

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 1:32 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
pony wrote:
DaveS wrote:
#ElseIf TargetWin32
// use IPCONFIG /all and parse the "Physical Address from "Local Area Connection" Block
// will be something like C4-2C-03-02-31-26 [C42c03023126 take first 11 char = C42C0302312]
sh.Execute("ipconfig /all")


That returns the MAC address. How about something like this instead
#ElseIf TargetWin32
sh.Execute("wmic bios get serialnumber")



For one thing... WMIC doesn't work on all installs of WinXP.... maybe Win7 or 8... but only some WinXP

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 1:59 pm 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
DaveS wrote:
For one thing... WMIC doesn't work on all installs of WinXP.... maybe Win7 or 8... but only some WinXP


Your Windows solution presents the MAC address, and not the machine serial number. In most cases what I posted will show the machine serial number, in your example it will never do that.

WMI is not available on Windows XP Home.

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Mon Mar 11, 2013 4:31 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
I realize what it returns..... and that that value can change if the network hardware is changed...

But WMI is not an option because as you specified
Quote:
WMI is not available on Windows XP Home.


The OP is free to choose (or not choose) any provided solution, and/or mix and match portions to fit his/her needs

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 1:30 am 
Offline

Joined: Wed Feb 16, 2011 1:59 pm
Posts: 74
Location: Arizona, USA
I consider myself a super noob on this stuff; but for what it's worth;
the following vbscript gives basic board info:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_BaseBoard")
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Version: " & objItem.Version
Wscript.Echo "Part Number: " & objItem.PartNumber
Wscript.Echo "Serial Number: " & objItem.SerialNumber
Next

this one basic ethernet adapter info:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapter")
For Each objItem in colItems
Wscript.Echo "AdapterType: " & objItem.AdapterType
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "MAC Address: " & objItem.MACAddress
Next

If I had the slightest idea of what I was doing, I'm sure this could yield something. Basic resource found here:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

I would still go the MBS route.

_________________
Windows XP SP3
RS 2012r2


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 8:11 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
But once again... you are ASSUMING that the WMI service is available, and in XP HOME it is not.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 8:31 am 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
DaveS wrote:
But WMI is not an option because as you specified
Quote:
WMI is not available on Windows XP Home.


At which point your hack would catch it

If s="" Then s="Z98888AAAQ2" ' could not get REAL value.. so use something bogus

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 8:38 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
done arguing..... I posted some code... use it .. or don't.... modify it ... or don't

I'm not sure why this advesarialy attitude erupted here.... I used MAC address because WMI is not 100% available..... use it or not....

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 11:09 am 
Offline

Joined: Wed Feb 16, 2011 1:59 pm
Posts: 74
Location: Arizona, USA
DaveS wrote:
But once again... you are ASSUMING that the WMI service is available, and in XP HOME it is not.


A portion of it must be, because those scripts I created and ran on my XP (HOME version) machine. And they returned the proper readouts. And I'm not arguing; I like the code you posted; it is simple and straightforward. I'm just presenting other options, which I did not existed until this post came to be.

_________________
Windows XP SP3
RS 2012r2


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 12:24 pm 
Offline
User avatar

Joined: Tue Mar 04, 2008 1:20 pm
Posts: 95
DaveS wrote:
This works for OSX and WINDOWS..... NO PLUGINS REQUIRED


#If Not DebugBuild
#pragma DisableBackgroundTasks
#pragma DisableBoundsChecking
#pragma DisableAutoWaitCursor
#pragma StackOverflowchecking False
#pragma NilObjectChecking False
#EndIf
Dim sh As New Shell
Dim s As String
Dim x As Integer
If reg_key<>"" Then Return reg_key

#If TargetMacOS
//sh.execute "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"
sh.execute "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep ""Serial Number (system):"""
s=sh.Result
x=InStr(s,"=")
If x=0 Then x=InStr(s,":")
If x>0 Then s=ReplaceAll(Trim(Mid(s,x+1)),Chr(34),"")
#ElseIf TargetWin32
// use IPCONFIG /all and parse the "Physical Address from "Local Area Connection" Block
// will be something like C4-2C-03-02-31-26 [C42c03023126 take first 11 char = C42C0302312]
sh.Execute("ipconfig /all")
If sh.ErrorCode = 0 Then
s = sh.Result
s = Mid(s,InStr(s,"Local Area Connection")+21)
s = Mid(s,InStr(s,"Physical Address")+16)
s = Left(s,InStr(s,EndOfLine))
s= Left(ReplaceAll(Trim(Right(s,19)),"-","")+"Q9734WF",11)
End If
#EndIf
If s="" Then s="Z98888AAAQ2" ' could not get REAL value.. so use something bogus

Return s


What happens if the OS is not English? You will not get the correct results.
What happens if an update changes in the OS and breaks your code ?

The correct way is to always use the API that is built into the OS.

_________________
iMac 2011, OSX Mountain Lion 10.8.1, Real Studio 2012r2.1


Top
 Profile  
Reply with quote  
 Post subject: Re: Serial No of hardware
PostPosted: Tue Mar 12, 2013 12:37 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
WOW...

Quote:
What happens if the OS is not English? You will not get the correct results.
What happens if an update changes in the OS and breaks your code ?


Since when are Mac Addresses and Serial Numbers Language specific?
What happens if the next release of an OS breaks the existing API (don't say that won't happen..... think CARBON vs COCOA)

So ALL solutions have a risk..... don't like my solution... post one of your own please.... don't say "use the API"... show HOW to use the API... this way we all learn something

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group