anchor.diff:  CALL :locate_file RELAY %~dp0relay.jar %~dp0relay\build\libs\relay.jar
   
   ::main
  -IF NOT "%2"=="" SET serial="-s %2"
  -CALL :do_%1 %serial% 2>NUL || CALL :do_help 
  +IF NOT "%2"=="" (
  +    FOR /f " tokens=2*" %%a IN ("%*") DO (
  +        IF "%%a"=="-d" ( SET serial= ) ELSE ( SET serial=-s %%a )
  +        SET dns=%%b
  +    )
  +)
  +IF NOT "%3"=="" (
  +    FOR /f " tokens=1*" %%a IN ("%dns%") DO (
  +        IF "%%a"=="-d" ( SET dns=%%b) 
  +    )
  +)
  +CALL :do_%1 %serial% %dns% || CALL :do_help 
   GOTO :eof
   
   :do_help
  
positive.code:     ECHO      If several devices are connected via adb, then serial must be
      ECHO      specified.
      ENDLOCAL
      EXIT /B
  
  
  :locate_file
  
negative.code:         SET VAR_NAME=%%a
          SET ALL_BUT_FIRST=%%b
      )
      CALL where /q %VAR_NAME%
      IF ERRORLEVEL 1 (
          FOR %%G IN (%ALL_BUT_FIRST%) DO (
              IF EXIST %%G (
                  SET FNAME=%%G
              )
          )
          IF "!FNAME!"=="" (
              SET FNAME=%2 & ECHO cannot find file, using default diretory %2
          )
      ) ELSE (
          SET FNAME=%VAR_NAME%
      )
      ENDLOCAL&SET %VAR_NAME%=%FNAME%
      EXIT /B 0
  
  :do_install
      ECHO Installing gnirehtet...
      CALL %ADB% %~1 install %APK%
      EXIT /B 0
  
  :do_uninstall 
      ECHO Uninstall gnirehtet...
      CALL %ADB% %~1 uninstall com.genymobile.gnirehtet
      EXIT /B 0
  
  :do_reinstall
      SETLOCAL
      CALL :do_uninstall %1
      CALL :do_install %1
      ENDLOCAL
      EXIT /B 0
  
  :do_stop
      ECHO Stopping gnirehtet...
      CALL %ADB% %~1 shell am startservice -a com.genymobile.gnirehtet.STOP
      EXIT /B 0 0
  
  :do_relay
      ECHO Starting relay server...
      START /I "gnirehtet_relay_server" %JAVA% -jar %RELAY%
      EXIT /B 0
  
  :do_start
      SETLOCAL
      FOR /f " tokens=1*" %%a IN ("%*") DO (
  
          set ALL_BUT_FIRST=%%b
      )
      IF NOT "%ALL_BUT_FIRST%"=="" (
          set dparam="--esa dnsServers %ALL_BUT_FIRST%"
      )
      ECHO Starting gnirehtet...
      CALL %ADB% %~1 reverse tcp:31416 tcp:31416
      CALL %ADB% %~1 shell am startservice -a com.genymobile.gnirehtet.START %dparam%
      ENDLOCAL
      EXIT /B 0
  
  :do_killserver
      SETLOCAL EnableDelayedExpansion
      SET filter="WINDOWTITLE EQ gnirehtet_relay_server"
      FOR /F "tokens=2" %%I in ('"TASKLIST /NH /FI %filter%"') DO SET PID=%%I 2>1
      TASKKILL /PID !PID!
      ENDLOCAL
      EXIT /B 0
  
  :do_rt
      CALL :do_install %1
      CALL :do_relay
      CALL :do_start %*
      EXIT /B 0
  
  :do_kill
      CALL :do_stop %1
      CALL :do_killserver
      EXIT /B 0
  