How to Get ID of Hard Disk or Motherboard

Hi all!

Is this possible to get the ID of the Hard Disk or motherboard in xojo? I want to get this in order to when I run my app. If the ID of the HDD or MoBo is not the registered one then the App will be unable to run.

Thanks :smiley:

I wanna do this on the 3 environments: Windows, Linux and Mac. But at this time I’m interested on Windows

this is what I use
 reads the MacAddress for Windows
YES
 that can change, but so could the HDD or MB serials
no idea what to do for Linux

  #If TargetMacOS
    sh.execute "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"
    s=sh.Result
    x=InStr(s,"=")
    If x>0 Then s=ReplaceAll(Trim(Mid(s,x+1)),ChrB(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= ReplaceAll(Trim(Right(s,19)),"-","")
    End If
  #EndIf

in OSX Terminal
system_profiler | more > /Users/username/Desktop/myreport.txt

gives you Serial Numbers (HDD, RAM 
)

[quote=198497:@Dave S] #If TargetMacOS
sh.execute “/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber”
s=sh.Result
x=InStr(s,"=")
If x>0 Then s=ReplaceAll(Trim(Mid(s,x+1)),ChrB(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= ReplaceAll(Trim(Right(s,19)),”-","")
End If
#EndIf[/quote]
Sh its a command Line? how can I declare it?

Thanks

Dim sh As New Shell

This isn’t working?

Dim SIP as string

SIP=System.GetNetworkInterface.MACAddress

See http://documentation.xojo.com/index.php/NetworkInterface

For Linux, see http://coffer.com/mac_info/locate-unix.html
and http://www.linuxquestions.org/questions/linux-hardware-18/hard-drive-serial-number-23071/

I don’t recall
 (for Windows), but it seems there are (or could be multiple MacAddresses) and that was the only way I could be sure to always get the same one.

OR
 it could be 
 I didn’t know about that command
 :smiley:

I wrote that piece of code quite a while ago, and just copy/paste it into new projects as required.

Yes, there could be several network interfaces. All he has to check is if the registered one is one of them.

A variation on http://documentation.xojo.com/index.php/NetworkInterface.MacAddress

Have a method IsRegistered( registeredMacAdress as string ) as Boolean

[code]For i as Integer = 0 to System.NetworkInterfaceCount-1

Dim n as NetworkInterface
n = System.GetNetworkInterface( i )

If registeredMacAdress = n.MACAddress then return True

Next

Return False[/code]

true
 my code doesn’t stop with what I posted
 it takes the value in “s” and uses it as part of a private/public key 
 so looping thru all possible values was not desired.

for SATA HDD (OSX)

dim s as String dim sh as new Shell sh.Execute "system_profiler SPSerialATADataType" s = NthField(sh.Result, "Serial Number: ", 2) s = NthField(s, EndOfLine, 1) MsgBox s

[quote=198504:@Dave S]I don’t recall
 (for Windows), but it seems there are (or could be multiple MacAddresses) and that was the only way I could be sure to always get the same one.

OR
 it could be 
 I didn’t know about that command
 :smiley:

I wrote that piece of code quite a while ago, and just copy/paste it into new projects as required.[/quote]
It gives the Serial (In Mac) and the Name Machine (on Windows) Right?

Regards

Just be aware that the serial number can be “lost”. A few years ago I had a motherboard in a MBP replaced and afterwards the serial number was blank. According to Apple this was normal.

From another post:

[quote]A not so well known fact is the Mac’s serial number (held on the logic board) is also easily changed (applies to later PPC and intel machines). Replacing the logic board could change the serial number, or leave you with a machine with no serial number (unless the tech remembers to write the new serial number to the board). Typically a logic board that has built in ethernet/bluetooth etc will also come with a new MAC address sticker to attach to the machines physical serial number label. Sometimes Apple has to strip logic boards from brand new machines to meet repair demands, and these boards have their host machines serial number (again, unless the tech remembers to change it).

For warranty purposes the machines physical serial number is used, ie the label.

I hold, and have done so for many years, many Apple hardware and software certifications; my continued connection with an Apple Service Provider, along with my credentials, gives me access to Apple GSX. Several officially endorsed Apple utilities exists to set the serial number on a logic board following a repair. An unscrupulous user could ‘clone’ serial numbers between logic boards. This is extremely unlikely, but given how pedantic some users are on here I thought I’d throw in my 2 cents . . .

[b]Summary

The serial number is written to the logic board, not the HD.

It is trivial, with the right software, to modify the serial number of the logic board (the one you see in “About this Mac” by clicking twice on the OS version, and in “System Profiler”).

Apple uses the physical serial number (the label) to identify your machine for warranty purposes.

It is possible to have no serial number on the logic board, or an invalid serial number, or one that does not match the label on your machine.[/b][/quote]

for the MAC Adress(es) in OSX

  dim s, st as String
  dim sh as new Shell
  sh.Execute "system_profiler SPNetworkLocationDataType | grep ""Hardware (MAC) Address:"""
  s = sh.Result
  
  for i as integer = 0 to CountFields(s, "Hardware (MAC) Address:")
    st = st + NthField(s, "Hardware (MAC) Address:", i)
  next
  MsgBox st

if you use MBS Plugins, see SystemInformationMBS module:

http://www.monkeybreadsoftware.net/module-systeminformationmbs.shtml

[quote=198573:@Christian Schmitz]if you use MBS Plugins, see SystemInformationMBS module:

http://www.monkeybreadsoftware.net/module-systeminformationmbs.shtml[/quote]
It sounds better!

SystemInformationMBS.MachineID

Thanks, cuz as you said, MAC address can be faked, and will be useless

[quote=394710:@Gerardo GarcĂ­a]It sounds better!

SystemInformationMBS.MachineID

[/quote]

Not only that, but you can use various pieces of information from SystemInformation MBS (my selections vary by OS and availability of which things come back empty for that machine) and then use them as part of the input to RegistrationEngineMBS which has all sorts of wonderful options. For example I set the Alphabet property to avoid similar looking characters in some fonts (such as 0/O or l/I). I purposely do not use any network interface Mac address as one of the variables.

It’s not that I couldn’t come up with my own way of getting at some of the information, or another registration scheme. It’s that MBS has such a plethora of incredibly useful, already written and tested functions that get continually expanded and enhanced. Plus I did nothing to get 64-bit compatibility, where often use of Declares would have required me to revisit how I’d implement something on my own. For the price, the complete MBS set is a no-brainer (IMHO).

Or better yet, get the 2018 Omegabundle to also get numerous other useful things. Incidentally, it also includes another registration scheme with GuancheMOS though I have no experience with it, having used MBS for years.

Thanks so much @Douglas Handy it was very useful for me.

As you say, I can compliment to reinforce the security of registered apps.
And never use MacAdress as a variable, cuz this can be changed. Or in case of a laptop have two MacAdress (Wifi,LAN)