1. Home
  2. Knowledge Base
  3. SureMDM
  4. How to Retrieve AnyDesk ID Using Android Custom Device Property in SureMDM
  1. Home
  2. Knowledge Base
  3. Android Management
  4. How to Retrieve AnyDesk ID Using Android Custom Device Property in SureMDM

How to Retrieve AnyDesk ID Using Android Custom Device Property in SureMDM

Purpose

This article explains how to create a Custom Device Property in SureMDM to retrieve the AnyDesk ID from rooted Android devices.

The script reads the “ad.anynet.id” value from the AnyDesk configuration file and displays it as a custom property in the SureMDM device grid.

This solution is useful when administrators want to remotely identify devices using their AnyDesk ID.

Prerequisites

  • Android devices must be rooted
  • Devices must be enrolled in SureMDM
  • SureMDM JavaScript support should be available
  • AnyDesk application should already be installed on the device

Objective

Retrieve the following value from the AnyDesk configuration file: ad.anynet.id

and display it as a Custom Device Property in the SureMDM Console.

Script

Use the following JavaScript while creating the Custom Device Property:

function assignValue(){

    var anydeskId = 20;

    var anydeskPaths = [

        “/data/user_de/0/com.anydesk.anydeskandroid/files/.anydesk/system.conf”,

        “/data/user_de/0/com.anydesk.anydeskandroid.custom/files/.anydesk/system.conf”,

        “/data/user_de/0/com.anydesk.anydeskandroid/files/.anydesk_ad_50888cd5/system.conf”,

        “/data/user_de/0/com.anydesk.anydeskandroid.custom/files/.anydesk_ad_50888cd5/system.conf”,

        “/data_mirror/data_de/null/0/com.anydesk.anydeskandroid/files/.anydesk/system.conf”,

        “/data_mirror/data_de/null/0/com.anydesk.anydeskandroid.custom/files/.anydesk/system.conf”,

        “/data_mirror/data_de/null/0/com.anydesk.anydeskandroid/files/.anydesk_ad_50888cd5/system.conf”,

        “/data_mirror/data_de/null/0/com.anydesk.anydeskandroid.custom/files/.anydesk_ad_50888cd5/system.conf”

    ];

    var cmdTemplates = [

        “su 0 cp {src} /sdcard/system.conf”,

        “su -c cp {src} /sdcard/system.conf”,

        “echo \”cp {src} /sdcard/system.conf\” | su”

    ];

    var found = false;

    for (var c = 0; c < cmdTemplates.length && !found; c++) {

        for (var p = 0; p < anydeskPaths.length && !found; p++) {

suremdmjs.deleteFile(“/sdcard/system.conf”);

var pStrScript = cmdTemplates[c].replace(“{src}”, anydeskPaths[p]);

            suremdmjs.executeRunscript(pStrScript);

            // Wait for cp to finish

            var waitTimeMs = 3000;

            var start = new Date().getTime();

            while (new Date().getTime() < start + waitTimeMs) {}

            var anydeskConf = suremdmjs.getDataFromFile(“/sdcard/system.conf”);

            suremdmjs.deleteFile(“/sdcard/system.conf”);

            if (anydeskConf) {

                var match = anydeskConf.match(/ad\.anynet\.id=(\d+)/);

                if (match) {

                    anydeskId = match[1];

                    found = true;

                }

            }

        }

    }

    return anydeskId;

}

Steps to Create the Custom Device Property

  1. Log in to the SureMDM Console
  2. Navigate to:
    Account Settings → Device Properties → Custom Device Properties
  3. Click on Add 
  4. Select the Platform “Android
  5. Enter the key and Select the Datatype
  6. Check-in “Retrieve Value Using Script
  7. Paste the above script
  8. Enter the “Frequency to retrieve the value
  9. Save the property
  10. Allow the devices to sync with the SureMDM server

Expected Behavior

  • The script reads the AnyDesk configuration file
  • Extracts the ad.anynet.id value
  • Displays the AnyDesk ID in the Custom Device Property column within the device grid

Troubleshooting

If the property displays 20:

  • Verify the device is rooted
  • Ensure su access is properly granted
  • Confirm the AnyDesk application is installed
  • Verify the configuration file exists on the device
  • Check whether the file path differs on the affected devices

Conclusion

Using a Custom Device Property with JavaScript allows administrators to retrieve and display the AnyDesk ID directly within the SureMDM Console. This improves device identification and remote management capabilities for environments using AnyDesk on rooted Android devices.

Need more help? Here’s how to get help from our experts. 

CONTACT US 

Was this helpful?
YesNo
Updated on June 2026
Need Support?
Can't find the answer you're looking for?
Contact Support