I created the following TcpConn.bat script that gets the information on open tcp connections from an android device, with an interval of two seconds, running in the adb shell.
:startTCP
adb shell cat /proc/net/tcp
timeout /t 2
goto startTCP
When testing this in my /dev/test/ folder the script ran as expected and gave me the expected output of sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
.
However when I moved it to my /dev/batchFiles/ folder it started running the contents of a different .bat script in that folder (called adb.bat
). with the contents
cd C:\Android\sdk\platform-tools
adb logcat -s Unity PackageManager dalvikvm DEBUG
Now in my TcpConn.bat script I execute "adb shell...", which matches the name of "adb.bat" without the extension, so it seems to make a call to this.
My question is though, why would it execute that script? I don't want it to execute the script, but run the adb command I'm not:
call
as explained herestart
Do batch scripts always check the directory for a file matching part of a command and run that file, even if it doesn't have an extension appended to it? If so is there a way to disable this behaviour?
I'm aware I can just rename the "adb.bat" file and be done with it. But want to know why it gets run. The only thing i could somewhat related to this is "How to run batch script without using *.bat extension"
As long as there is a batch file in the same directory as the one you are executing then it will execute that adb.bat file because the windows command prompt will look in the current directory first in search of an executable when you tell your batch file to execute a command.
As far as a solution to your problem I would say if it is possible then change the name of your adb.bat file to something else like adbFile.bat that way you won't be calling it every time you need to call your adb tools from that specific directory.