Running ADB Command After Clicking a Google Maps Link

Abstract: Automates ADB command execution on Android devices by intercepting custom Google Maps links via a Windows registry handler.

Created: 2026-07-31 by
You can run an ADB command after clicking a Google Maps link on Windows by creating a custom URL protocol handler. This involves registering a specific URI scheme in the Windows Registry that points to a batch file or script. When you click a map link using this custom scheme, Windows executes the associated script, which then triggers the desired Android Debug Bridge action on your connected device.

Understanding the Mechanism

Google Maps links typically use the https:// or http:// protocols. To intercept these clicks and trigger an ADB command, you cannot modify Google's server-side output. Instead, you must create a client-side bridge. The most reliable method is defining a custom protocol, such as mapsadb://. When a user clicks a hyperlink with this scheme, the operating system looks up the registered handler and executes the specified program. This approach decouples the web interaction from the device management task, allowing for precise control over when and how the ADB command runs. This technique is particularly useful for automation workflows where you want to send location data or launch specific intents on an Android device directly from a browser session. It avoids the need for manual command-line entry every time a new map coordinate is identified. By automating this step, you reduce latency between identifying a target location and executing actions on the device.

Creating the Execution Script

The first step is to create a script that Windows will execute. A batch file is the simplest solution for Windows environments. Create a new text file and name it handle_maps.bat. Inside this file, you need to parse the arguments passed by the URL and translate them into an ADB command. Open the file in a text editor and add the following logic:
@echo off
REM Extract the query string from the URL argument
set "url=%~1"
REM Remove the protocol prefix mapsadb://
set "data=%url:mapsadb://=%"

REM Example: Parse latitude and longitude if present
REM For simplicity, this example just sends a generic toast or intent
REM You would replace this line with your actual ADB command
adb shell am start -a android.intent.action.VIEW -d "%data%"

REM Optional: Pause to see output
pause
Ensure that the path to your adb.exe is either in your system's PATH environment variable or specify the full path in the script (e.g., C:\Users\YourName\AppData\Local\Android\Sdk\platform-tools\adb.exe). If you encounter issues with spaces in paths, refer to our guide on Batch File Not Working with Space in File Name to properly escape characters. Save the file in a secure directory, such as C:\ADB_Handlers\. Test the script manually by opening a command prompt and running handle_maps.bat mapsadb://example.com to verify it launches correctly without errors.

Registering the Protocol in Windows Registry

Once the script is ready, you must tell Windows how to handle the mapsadb:// scheme. This is done via the Windows Registry. You can create a .reg file to automate this process safely. Create a new text file named register_protocol.reg and paste the following content, adjusting the path to your batch file as needed:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\mapsadb]
@="URL:MapsADB Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\mapsadb\DefaultIcon]
@="C:\\ADB_Handlers\\handle_maps.bat,1"

[HKEY_CLASSES_ROOT\mapsadb\shell]

[HKEY_CLASSES_ROOT\mapsadb\shell\open]

[HKEY_CLASSES_ROOT\mapsadb\shell\open\command]
@="\"C:\\ADB_Handlers\\handle_maps.bat\" \"%1\""
Note the double backslashes in the file path; this is required for registry syntax. Double-click the .reg file and accept the prompts to merge it into the registry. After doing so, Windows associates the mapsadb scheme with your batch file. If you have previously set a different default application for unknown protocols, you may need to clear your browser's site settings for permissions. In Chrome, go to Settings > Privacy and security > Site Settings > Additional permissions > Custom handlers. Ensure that the new handler is recognized.

Testing the Integration

To verify the setup, open any web browser and navigate to a page containing a link formatted as <a href="mapsadb://com.google.android.apps.maps">Launch Maps</a>. Click the link. Windows should display a security prompt asking which app to use. Select your batch file or the default handler if configured correctly. The script should execute, and the ADB command defined within it should run on your connected device. Check the ADB logcat or the device screen to confirm the action took place. If nothing happens, check the Event Viewer in Windows under Applications logs for errors related to the batch file execution. Common issues include incorrect file paths, missing quotes around arguments, or ADB not being able to communicate with the device due to permission issues. For users who find themselves needing to manage other system-level interactions, understanding how to isolate processes can be helpful. While this topic focuses on ADB, similar principles apply to managing audio outputs, as discussed in How to Disable Sound from a Windows Application, ensuring your debugging sessions remain uninterrupted by background noise.

Frequently Asked Questions

Can I use PowerShell instead of a batch file?

Yes, you can register a PowerShell script as the handler. Change the command in the registry to point to powershell.exe -File "C:\path\to\script.ps1" %1. Ensure your execution policy allows running local scripts, or use the -ExecutionPolicy Bypass flag in the command line.

Why does the ADB command fail even though the script runs?

This usually happens because the script runs in a context where the adb executable is not in the PATH. Always use the absolute path to adb.exe in your script. Additionally, ensure your device is connected and authorized via USB debugging before clicking the link.

Is it safe to register custom URL protocols?

It is generally safe as long as you trust the source of the registry changes. Custom protocols do not grant elevated privileges by default. However, avoid registering schemes that mimic official system protocols (like file:// or http://) to prevent conflicts or security vulnerabilities.

How do I remove the custom protocol handler?

To remove the handler, delete the HKEY_CLASSES_ROOT\mapsadb key from the Registry Editor. You can also create a .reg file with - before the key path (e.g., [-HKEY_CLASSES_ROOT\mapsadb]) and merge it to delete the entries cleanly.

Can I pass complex JSON data through the URL?

Standard URLs have length limits and character restrictions. For complex data, consider encoding the payload using Base64 or passing a reference ID that the script fetches from a local database or API. Avoid putting raw JSON directly in the URL query string to prevent parsing errors in the batch file.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More