Jump to content
Inpho

Getting serial number from Samsung mobile device without adb

Recommended Posts

Hi All,

I didn't know where to put this; my apologies if this is the wrong location.

When you plug a Samsung mobile device (phone, tablet, etc.) into the USB of a Windows PC, you can right-click the device in My Computer and select Properties. Here, it will show you the correct serial number of the device. Clearly Windows doesn't use adb to get the SN so I'm stuck at how to get the SN without adb and where the device doesn't have a drive letter assigned to it.

When I last picked this up, I tried seemingly everything I could from wmi(?) and winmgmts(?) but either it's hidden cloak-and-dagger style or I can't see the forest for the trees...

Does anyone know what API Windows uses when getting the serial number of a device Windows calls a Portable Media Player?

20191009_135630.jpg

Share this post


Link to post
Share on other sites

So I went down a rabbit hole, and I'm still looking, but I got to here eventually: https://docs.microsoft.com/en-us/windows/win32/api/mswmdm/nf-mswmdm-iwmdmdevice-getserialnumber

I think you might need to install a special SDK to use the method, but I'm honestly not sure.

As an alternate solution... you might be able to monitor the registry. I think that what this person did. I have too many USB hubs or something at work and I can't find my phone after plugging it in (Galaxy S7), but you might be able to. To anyone on Win10, it looks like the registry matches pretty well to Win7. (It looks like you have Win7, right?)


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Share this post


Link to post
Share on other sites

I'm using Win7 to develop the tool, but the tool runs on a mix of Windows 7 and 10 machines. This tool is called Hubble (as it inspects Samsung Galaxy devices heh).

I work in the industry and have almost infinite devices to test on (from Galaxy S/S1 to Galaxy Folds) so I'll look into your advice tomorrow as it's almost EOD for me.

Thanks for the info :)

Share this post


Link to post
Share on other sites

I'm making some progress; this "solution" works on my work PC but I'll have to travel to the workshop to get some technicians to test this tomorrow.

I'm doubting this is universal but here it is for now. Returns serials from ALL devices inserted since last logon by the looks of it so an internal exclusion list will have to be added to as it goes along. More testing tomorrow.

Global Const $sStripClass = "#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"
Global Const $sStripIdentifier = "\??\USB#VID_04E8&PID_6860#"

Func DevicesGet()

    Local $sSubKey = ""
    Local $sKeys = ""
    Local $aKeys

    ; Loop from 1 to 10 times, displaying registry keys at the particular instance value.
    For $i = 1 To 10
        $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_04E8&PID_6860", $i)
        If @error Then ExitLoop
        $sKeys &= $sSubKey & ","
    Next
    If $sKeys <> "" Then
        $sKeys = StringTrimRight($sKeys, 1)
        $aKeys = StringSplit($sKeys, ",")
    EndIf

    Return($aKeys)

EndFunc   ;==>Example

$aSerials = DevicesGet()

For $i = 1 To UBound($aSerials) - 1

    $s = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_04E8&PID_6860\" & $aSerials[$i] & "\Device Parameters", "SymbolicName")
    $s = _StringTrimLeft($s, "#", 0, 2)

    $s = _StringLeft($s, "#")

    ConsoleWrite($s & @CRLF)

Next

; #FUNCTION# ====================================================================================================================
; Name ..........:  _StringTrimLeft
; Description ...:  Searches for a string inside a string, then removes everything on the left of that string
; Syntax ........:  _StringTrimLeft($sString, $sRemove[, $iCaseSense = 0, $iOccurrence = 1])
; Parameters ....:  $sString            - a string value. The string to search inside.
;                   $sRemove            - a string value. The string to search for.
;                   $iCaseSense         - an integer value. Flag to indicate if the operations should be case sensitive.
;                   $iOccurrence        - an integer value. Which occurrence of the substring to find in the string. Use a
;                                         negative occurrence to search from the right side.
; Return values .:  Success             - String
;                   Failure             - Empty string as returned from StringTrimLeft()
; Author ........:  Sam Coates
; ===============================================================================================================================
Func _StringTrimLeft($sString, $sRemove, $iCaseSense = 0, $iOccurrence = 1)

    Return (StringTrimLeft($sString, StringInStr($sString, $sRemove, $iCaseSense, $iOccurrence) + StringLen($sRemove) - 1))

EndFunc   ;==>_StringTrimLeft

; #FUNCTION# ====================================================================================================================
; Name ..........:  _StringLeft
; Description ...:  Searches for a string inside a string, then removes everything on the right of that string
; Syntax ........:  _StringLeft($sString, $sRemove[, $iCaseSense = 0, $iOccurrence = 1])
; Parameters ....:  $sString            - a string value. The string to search inside.
;                   $sRemove            - a string value. The string to search for.
;                   $iCaseSense         - an integer value. Flag to indicate if the operations should be case sensitive.
;                   $iOccurrence        - an integer value. Which occurrence of the substring to find in the string. Use a
;                                         negative occurrence to search from the right side.
; Return values .:  Success             - String
;                   Failure             - Empty string as returned from StringLeft()
; Author ........:  Sam Coates
; ===============================================================================================================================
Func _StringLeft($sString, $sRemove, $iCaseSense = 0, $iOccurrence = 1)

    Return (StringLeft($sString, StringInStr($sString, $sRemove, $iCaseSense, $iOccurrence) - 1))

EndFunc   ;==>_StringLeft

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By rudi
      Hello,
       
      I found a couple of threads asking quite similar questions, but without finding a "straight" solution to Access the internal phone storage as well as the plugged in SD-Card.
       
      While the SD Card is quite an easy Job (shutdown phone, remove SD, plug into some Card Reader, Access it using a drive letter), the internal storage isn't accessible this way.
       
      Of course I *CAN* Access all the (regular visible) Content, when connected to a Windows box.
       
      But this way I cannot estimate, where all the space was eaten up. So I'd like to know, how to address the "root" Folder of the internal storage of my Android Phone to get it's subfolders and files. Going through the whole Folder tree recursively isn't my Problem, it's just howto address the very first Folder and then to read all files (with sizes) and names of the subfolders.
       
       
      Regards, Rudi.
    • By wisem2540
      I am a huge autoit fan and have written several graphical apps.  I would love to get started building simple and complex android apps.  I am hoping someone here can recommend a good platform to get started with.  Preferably something that had an Autoit-like feel
    • By Miliardsto
      Hello Im wondering if using this https://ohtejera.github.io/ImperiusAutoIt/#started
      UDF can i make that I can control my windows application with phone?
      like for example click button Start on android phone and then something would be done in my windows app?
    • By mmoalem
      Hi all - was wondering if the following is possible:
      I have a motion detecting ccrv software on PC (icam or similar) - there is a bottom that turn surveillance (motion detection) on and off. I can get autoit to automate the clicking on the button. 
       
      I want my android phone to send a trigger every time it disconnect from the home network (i.e when I leave home) to tell autoit to turn on surveillance and when reconnecting to home network to trigger it to click off
       
      does any one have a suggestion how to go about achieving this?
    • By gillesg
      Hello all,
      First, I wish you a happy new year.
      I am building with autoit a substitution tool to sync my iTunes playlist with my android phone.
      I have managed reading the itunes lib, but now I am stuck at reading / writing on my android device.
      From all the searches I made, it is using MTP protocol. 
      The Windows Explorer can read and write on the device.
      The device appears as a "portable device".
       
      Does anyone of you can direct me in some direction to keep investigate.
       
      Thanks in advance
       
      Gilles
×
×
  • Create New...