Today I want to show you how to use DeskDock to control your phone from your desktop….WIRELESSLY. I have been using DeskDock for a while now and I love it. I don’t love that I have to keep my phone plugged in all day to use it though. Today I had a revelation that, frankly, took way too long to happen. DeskDock simply uses ADB commands to control your phone, and ADB CAN work wirelessly. So, I gave it a shot and surprisingly it just worked. I already had DeskDock up and running but I’ll give a quick overview and links to the process. At the end I will share my script to automate the daily setup part.
Install DeskDock
Setting DeskDock up is pretty easy. You download the server program onto your PC and run it. On your Android phone you enable Developer mode and usb debugging, next download the app, run it, then plug in your usb cable. The main thing on the server side (your PC) is to make sure you have the right ADB drivers for your phone. I have a Pixel so I used this link. Also, here is the link to the setup from the developer of Deskdock.
PC (server) side setup
The only two prep-work we need to do is install Java (if you don’t already have it) and the ADB drivers for you phone.
Install Java
You can install java from their website or if you have Chocolatey you can simply run
choco install jre8 -y
Install ADB USB Driver
Installing ADB drivers is pretty easy as well, its really just about downloading the right one. I have a Pixel so I used the one here but if you have another type of phone you should find the right drivers in this list.
Download and run the server app
Download the latest server app from here. Place the folder on the C:\ drive and rename it to DeskDockServer (no version number). You don’t need to put it on the C:\ drive if you just want to use DeskDock with a USB cable, BUT if you want to use my script you do. Now go into that folder and right click on the DeskDockServer.exe and hover over send to and click Desktop (create Shortcut). We will use this shortcut in the next step. Next, to get this to autostart we will add it to our startup folder. From the Run prompt (or cmd or pwsh) type in shell:startup and hit enter. This will open up your startup folder in explorer. Now copy or cut the shortcut we just made on the desktop into this folder. Now, every time you login DeskDock will autostart. Go ahead and double click our new shortcut to start the server this time for our next steps.
Phone Side setup
For our phone setup we need to do a few things; Enable Developer mode, enable usb debugging and make sure wireless adb is enabled.
Enable Developer Mode
Enabling developer mode on android is pretty easy as well. Just go into settings, about phone and then tap your build number 8 times. This will enable the developer mode options.
Enable USB Debugging
Next we need to enable usb debugging. Do this from System, Advanced, Developer Options. Scroll down until you see USB Debugging and toggle it to on. After you do this step you can actually start using DeskDock, but with a usb cable only. If you want to NOT have to plug in every time you can enable wireless adb and that will allow you to control your phone without plugging in.
Enable Wireless ADB
Wireless ADB will kill itself when your phone reboots. You will need to do this step every time you reboot your phone. This is the manual way. Later in this post I will share a script that does this for us. To do this manually open an admin powershell window and path to the deskdock folder. If you followed my advice above it will be at c:\ so the command would be:
cd C:\DeskDockServer\win\
Lets check to see that the device is connected
.\adb.exe devices
This should return your devices as what looks like a serial number (see below image for all commands)
Run the following command to enable wireless adb. You CAN change the port but I recommend against it. If you plan on using Tasker for anything extra fancy it needs to be port 5555:
.\adb.exe tcpip 5555
This will just return “restarting in TCP mode port: 5555”
Next is to make the connection. The first time you do this you will get a permission prompt pop-up on your phone. Make sure you check the box that says always allow or you will need to accept each time. Replace $DeviceIP with the IP address of your phone. You can get it from the advanced section in the wireless menu. In the script later on I have a way to get it without looking at your phone settings.
.\adb.exe connect $DeviceIP
You are now connected to your phone and can control it with DeskDock wirelessly.
Script to Enable Wireless ADB and connect to phone
I was excited to get this working but I quickly realized what a pain this was going to be every morning. Before using DeskDock wirelessly I would come into work, boot my PC, open the DeskDock app on my phone, then plug in the USB cable (sometimes a few times!) and I and i would be off to the races. Now I need to open a powershell window and run a few commands each time and I have to make sure my IP didn’t change too. Boo! Enter powershell. I made a quick script that will do these things for us! This code is pretty short and I commented it like crazy so you should be able to follow along pretty easily. I made this in to an .exe as well that I put in my shell:startup folder so it starts up with my PC. It wont let me host exe files though so I will figure out how to do that and update the post. for now here is the powershell code:
### Make sure powerhsell is loaded as admin
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
### Load in the ability to make messagebox windows
Add-Type -AssemblyName PresentationCore,PresentationFramework
### Path to our Deskdock Dir that has ADB in it
cd C:\DeskDockServer\win
### Kill any existing instances of ADB server
.\adb.exe kill-server
### This makes a message box telling the user to plug in their device.
### We need to plug the device in this first time to enable wireless ADB
### as well as to get the IP address of the device so we can make our connection
[System.Windows.MessageBox]::Show('Plug the phone in now and click OK')
$IPmess = .\adb.exe shell ip route
$IPCleaner = $IPmess.Split(" ")
$IPIndex = $IPCleaner.count - 2
$DeviceIP = $IPCleaner[$IPIndex]
.\adb.exe tcpip 5555
.\adb.exe connect $DeviceIP
[System.Windows.MessageBox]::Show('Should be ok to unplug now')
### Device should be connected at this point. The below is just a look to kill and restart
### the adb server if your device goes off the network. When the device comes back the script
### will try to reconnect the device.
$DeviceConnect = $true
$pigs = "Flying"
while ($pigs -eq "Flying") {
# $TestConnection = Test-NetConnection -ComputerName $DeviceIP -Port 5555 | select -ExpandProperty TcpTestSucceeded
$TestConnection = .\adb.exe devices
if ($TestConnection[1]) {
Start-Sleep -Seconds 10
Write-Host "connected"
}
else {
.\adb.exe kill-server
$ping = $false
while ($ping -eq "False") {
$ping = Test-NetConnection -ComputerName $DeviceIP | select -ExpandProperty TcpTestSucceeded
Start-Sleep -Seconds 10
.\adb.exe kill-server
}
.\adb.exe connect $DeviceIP
}
}
Hello!
Idea how can this be achieved in MacOS?
Yes I believe this can be done in MacOS. Just make sure to download the MacOS version of DeskDock and the commands will essentially be the same since you are running the adb included with DeskDock. If ADB isnt included for some reason I’m SURE there is a way to get adb installed on a Mac. I use these same exact steps on my Linux pc and it works like a champ! Let me know if this helps!
I tried it for hours ik I’m doing something wrong but i just don’t know what is it.i placed the downloaded deskdock folder on c drive as said and the devices are connected when I open the command prompt in c/deskdock/win but if I click the command prompt using the search bar and open it which the directory is c/users/sneaky the devices aren’t connected and I get some long ass error code in red. And while I connect it using the c/deskdock/win it works fine and I get the code saying it’s connected and all but when I remove the cable the devices are gone ?? please help
Oh ok, when you open cmd from search it takes you to your “home” folder which for you sounds like C:\users\sneaky all you need to do to get to the C:\deskdock\win folder is type the following in cmd:
cd C:\deskdock\win
then you should be good to go. If you run into permission issues make sure you run cmd as admin by right clicking on the shortcut and then click ‘run as administrator’
thank you so much for this. but i have a little problem. from my understanding, as long as i don’t reboot my phone, i can just reconnect from powershell, right? the thing is, every time i restart my laptop, the connection is gone too, i can’t find any devices on adb devices command, i have to plug in the usb and run the script again. what am i doing wrong? is there any way to connect the wireless adb? because from what i understand, my phone is not switching off that wireless adb mode.
Glad this has mostly worked out good for you. The problem is when you reboot your laptop the script loses the DeviceIP variable so the script doesn’t know how to talk to your phone. What you can do is take the following lines out of the script and put them in a new, separate script for if you reboot your phone or your IP changes. Replace those lines you removed from the original script with $DeviceIP = “” obviously replace with your phones IP. That way when you reboot the script wont need you to plug your phone in to figure out its IP.
here are the lines to take out:
### This makes a message box telling the user to plug in their device.
### We need to plug the device in this first time to enable wireless ADB
### as well as to get the IP address of the device so we can make our connection
[System.Windows.MessageBox]::Show(‘Plug the phone in now and click OK’)
$IPmess = .\adb.exe shell ip route
$IPCleaner = $IPmess.Split(” “)
$IPIndex = $IPCleaner.count – 2
$DeviceIP = $IPCleaner[$IPIndex]
.\adb.exe tcpip 5555
.\adb.exe connect $DeviceIP
[System.Windows.MessageBox]::Show(‘Should be ok to unplug now’)
Any idea how can I uninstall this from my computer? it is very laggy and not very useful. I tried removing the folder in C:/ but it still appears in some places as the task manager.
The computer still tries to run it.
Thanks in advance!!
I’m not quite sure what you are seeing in task manager but to run this the only thing you “installed” was the driver for your phone. The actual app and the scripts only run if you start them. If you followed the guide and put the DeskDock server app in shell:startup then you need to delete it from there too otherwise it will still run each time you boot your PC. Again though, there is no program installed following this guide. Hope this helps!
You are completely right, thanks! 🙂
As I wrote the comment an idea came to mind and I already got to remove it.
Just hat to remove the shortcut from the AppData/Roaming/Microsoft/Windows/StartMenu/Programs/Start folder. Just in case it is useful for someone.
Cheers!
Yeah, my instance broke. Weaker connection in my home than I thought. I tried restarting my phone, and I still get this same dialog.
Output:
OK
error: device unauthorized. Please check the confirmation dialog on your device.
You cannot call a method on a null-valued expression.
At C:\Users\chris\OneDrive\Desktop\DeskDockServer_1.2.2\DeskDock Wireless.ps1:17 char:1
+ $IPCleaner = $IPmess.Split(” “)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Cannot index into a null array.
At C:\Users\chris\OneDrive\Desktop\DeskDockServer_1.2.2\DeskDock Wireless.ps1:19 char:1
+ $DeviceIP = $IPCleaner[$IPIndex]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
restarting in TCP mode port: 5555
Usage: adb connect [:]
OK
Usage: adb connect [:]
I think you your PC got put in the unauthorized list for ADB devices you can clear it by going into the developer options menu on your phone and go down to the debugging section, first make sure that USB debugging is on and then tap the “Revoke USB debugging authorizations”. Then un plug and replug your phone into your PC and re-run the script. It should work now. Make sure when it runs the ADB command to look at your phone and click “yes” when you get the usb debugging message. If you check the box that says remember, you wont have to do it every time you plug in.
Thank you It’s works. Device connected successfully.
But there is one problem it is disconnected when device screen locked. Please help me how to solve this issue. and I need your help for how to create and add script file in startup.