Capture Serial Number

Hello guys,

          I use a method of capturing the serial number of Macs with AppleScript, there is a way to capture the Serial Number for direct xojo?

Tanks for any help.

A quick google search shows that it could be done with a shell command. Maybe try this:
http://osxdaily.com/2011/04/25/get-mac-serial-number-command-line/

Hi Jason,

         How I use this on xojo Code ?

Have a look at http://documentation.xojo.com/index.php/Shell .

If you use our MBS Plugins, it would be
MsgBox SystemInformationMBS.MacSerialNumber

If you have the MacOSLib package, you can use MacSystemProfiler.

MsgBox MacSystemProfiler.HW_SerialNumber()

Tanks for all Guys !

I’ll make a more specific question, is there a native way to xojo capture the serial number of a Mac computer?

What’s not “native” about System Profiler?

try this…
https://www.mediafire.com/?sf256riyfpu3818

Kem, I did not refer unless native Mac OS but a direct way to make the code without downloading other libraries for Xojo!

This exact code will do it for you. The serial number will be in the variable sn:

  dim sh as new shell
  sh.Execute "system_profiler SPHardwareDataType | grep 'Serial Number'"
  dim sn as string = sh.Result.NthField( ":", 2 ).Trim

[quote=69935:@Kem Tekinay]If you have the MacOSLib package, you can use MacSystemProfiler.

MsgBox MacSystemProfiler.HW_SerialNumber() [/quote]

I get “This item does not exist” :frowning:

Sorry, you need the macoslib folder and my plist stuff from Additional Modules.

Works great :slight_smile: Thank you.

It is much faster than system_profiler.

Glad you like it.

Kem Tekinay, wanted to thank you so much to help, worked perfectly!

It is people like you who give me encouragement to continue studying programming, thank you and make sure that today made a friend here in Brazil!

You’re very welcome. :slight_smile:

this is what I use

  #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)),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

Dave, you soooo need to learn regular expressions. :slight_smile: