Jump to content

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

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.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

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 :)

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

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By t0nZ
      Computer Plucker is a fork and a "restoration" of Computer stats utility by @Rogue5099 (link)
      You can obtain various data about local machine, as from the screenshot.

      But my goal is not (only) to provide another PC stats tool, but to develop a very basic remote inventory tool, like (a small subset of) the abandoned Spiceworks or the Microsoft SCCM.
      So this script can be deployed on a machine as a standalone executable (yes you need only ONE file to distribute) , and launching the .EXE it installs itself to a folder (es. c:\autoit\computerplucker)
      In tools menù you can set two tasks and not only
      one for creating every week a file.ini with all the data of the machine. another one  for creating every week a file.ini with all the data of the machine PLUS uploading a CRYPTED record of the machine in a free mysql DB online For my needs, I am  deploying the .exe and schedule the second task, uploading data one time a week.
      In tools menù you will find also commands for:
      manual creating the .ini data file  to upload the data in crypted records to upload the data in clear text records (for testing..) total uninstall of ComputerPlucker, with a simple security code. many other tasks in not so logical order.. next version I have to tidy the menù... So my plan is to deploy this on my machines, and have the data in a online DB, this DB will be for me only a "cache" for data records to be downloaded (and deleted) by another script.
      As today the account of this TEST DB is embedded in code, using the "File to Base64 String' Code Generator" by @UEZ (used also for embedding icons and XML task definitions)
          Local $mysqlhost = "sql11.freemysqlhosting.net"
          Local $mysqlport = "3306"
          Local $mysqldb = "sql11403701"
          Local $mysqluser = "sql11403701"
          Local $mysqlpsw = "QtL7T9U5GV"
      The DB is one table of 30 mysql tinytext fields... very simple indeed...
      You can try to upload data to this DB and access (phpmyadmin or a random mysql browser app) to see the results.
      Or you can use my ComputerPluckerDBbrowser (see at the end of this post) a script to collect and manage the data.

      PRIVACY warning: you are uploading data of your PC account and PC data, test as your risk (or test in another account...)
       
      I also created a small post in a blog for not so geek friends, and I have a more advanced version of the data browser, you can have more info lookin' here. 😀
      Attached you will find the code, and all the necessary includes are at this >link<.
      ComputerPlucker.EXE is downloadable >HERE<
      ComputerPluckerDBbrowser.EXE is downloadable >HERE<
       
      ComputerPluckerDBbrowser_LITE.au3
       
      ComputerPlucker.au3

    • By mmoalem
      Hi there - creating a simple script to triger cctv software to turn on when my phone is not connected to home wifi. But having issues with my phone (samsung s7) not answering ping when sleeping (despite wifi set to work when sleep) - not sure the issue... and ideas? 
      Alternatively was wondering about pinging the bluetooth address of the phone - anyway to get this working in autoit?
    • 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?
×
×
  • Create New...