9

Very occasionally, I will want to edit a file, say /system/build.prop or /etc/hosts on my Android device. I find that the easiest way to do it is:

c:\> adb shell
$ su
# vi /etc/hosts

This works fine if I'm using Linux. However, attempting to run vi on my phone when using Windows results in a borked vi screen with strange characters. I'm assuming this is because cmd doesn't support ANSI control characters.

Is there any way to fix this (e.g., a cmd alternative that does the job)?

Chinmay Kanchi
  • 62,729
  • 22
  • 87
  • 114

5 Answers5

10

You can do it with PuTTYTray. It's an improved version of PuTTY which features a number of additional features. One of such feature is Android adb support. To use it:

  • Select Adb as Connection type
  • Enter -d (for single usb device) or device serial number in the host field
  • ???
  • PROFIT!!!

PuTTYTray configuration

Volo
  • 28,673
  • 12
  • 97
  • 125
  • 1
    Only this answer solved my problem of attempting to use full screen applications through the adb listener under Windows 7. As far as I can tell, ConEmu does nothing to resolve the described problem. I also tried running `adb shell` under bash from Windows to no avail. I suspect the problem is with Windows' `adb shell` command itself. PuTTYTray implements its own connection to the adb listener, which apparently includes full screen terminal emulation where `adb shell` doesn't. **Note:** Above, you say use -d in the host field, but your snapshot shows -a as the option. I used -a successfull. – CODE-REaD May 31 '16 at 20:49
  • @Code-Read yes, `-d` and `-a` are equivalents when there is only one device connected. Regarding `adb shell` you are right as well. AFAIK, PuTTYTray is the only reliable way to use `vi` and other full screen apps on the Android device when connecting from Windows. – Volo Jun 01 '16 at 15:09
  • What if your android is on WiFi. What option do you use then? I tried entering the IP address in the field where `-a` or `-d` etc are but it would crash as soon as I opened it. – Frak Jan 19 '20 at 06:34
4

This is a late answer to your question in 2012. I found that if I run Windows PowerShell, I can do "vi" under the adb shell.

Launch PowerShell (use your Android SDK location, not mine)

PS C:\Users\Me> cd Downloads\Android\Sdk\Platform-Tools
PS C:\Users\Me\Downloads\Android\Sdk\Platform-Tools> .\adb shell
root@vbox86p:/ # cd data/data/com.mycorporation.myproj/shared_prefs
root@vbox86p:/data/data/com.mycorporation.myproj/shared_prefs # vi log_prefs

I only used simple vi commands like 'o', 'esc', and ':wq', but it worked well using the full screen (none of the garbage you would see in the Windows Command Prompt).

Les
  • 10,335
  • 4
  • 40
  • 60
2

I've never had your exact problem, but it seems like Cygwin would be a good bet.

strange quark
  • 5,205
  • 7
  • 41
  • 53
0

What you basically need is a real commandline... Unix-style tools on Windows? MinGW http://www.mingw.org/ is a alternative to Cygwin that's worth looking into.

Community
  • 1
  • 1
Tulsi Leathers
  • 328
  • 1
  • 10
  • 1
    would be good but there's no adb for those and the normal windows ADB still sucks in a cygwin shell and MSYS. – Wyatt Ward Jun 15 '16 at 20:25
0

I finally found a tool working in Windows 2012 R2. You need to run cmder Download can be found here

Then run

cmder

Go to adb folder,

cd XXX

then

adb shell
su
cd /system/etc
vi hosts

displays correctly

Christophe
  • 597
  • 4
  • 14