unable to launch executable from within .bat file


  1. Posts : 2
    Windows 7 Ultimate x64
       #1

    unable to launch executable from within .bat file


    I am trying to get started with Google's Android Studio. I have installed the studio software and the Android SDK on my d:\ drive, as follows...

    d:\dev\android\android-studio
    d:\dev\android\sdk

    In the SDK, there is a .bat file, android.bat, that in turn calls another .bat file, find_java.bat.

    When I run android.bat, it fails to launch the second file...

    d:\dev\android\sdk\tools>android
    '"d:\dev\android\sdk\tools\lib\\find_java.bat" -s' is not recognized as an internal or external command,
    operable program or batch file.

    The following command entered on the command line does in fact run the find_java.bat file...

    d:\dev\android\sdk\tools\lib\\find_java.bat -s

    ...but the find_java.bat file cannot be found from within the android.bat file.

    I have sought help from Google, and the engineer assigned to the problem reports that when he runs android.bat on his machine, it works fine.

    Any suggestions as to why the same .bat file works on the Google machine and not on mine?

    The Google OS is Windows 7 Home Premium x64, mine is Windows 7 Ultimate x64.

    Thanks.

    Jerry
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hi Jerry,

    Would you like to zip and post both batch files here. I'll check for any possible syntax errors that may be present in the files.
      My Computer


  3. Posts : 2
    Windows 7 Ultimate x64
    Thread Starter
       #3

    Okay, see attached.

    I've zipped up the tools and lib folders from the android sdk with all but the two .bat files in question deleted.

    When you run the android.bat file in tools, it should run lib\find_java.bat. On my system, instead, I get an error message that says the file can't be found.

    (You may see some other extraneous error messages about missing resources, because they are, well, missing since I deleted them.)

    The critical thing is that when I run the android.bat file in this collection, it is unable to locate lib\find_java.bat even though that file is present in the specified location.
    unable to launch executable from within .bat file Attached Files
      My Computer


  4. Posts : 1,849
    Windows 7 pro
       #4

    You probably have to call the first bat from within a command prompt. I know enough about windows scripting to know that the executable cscript might work but I don't know that for sure. Using the command-based script host (CScript.exe)
      My Computer


  5. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #5

    Hi Townsbg. Apologies for any insolence but I must invalidate a few misleading details you've made in your post above.

    townsbg said:
    You probably have to call the first bat from within a command prompt.
    Judging by how Jerry was able to explain his situation with references to real command prompt errors, and also the fact that he directly mentions his use of the command line...

    jerryford said:
    The following command entered on the command line does in fact run the find_java.bat file...
    ...You can already assume that Jerry has attempted running both scripts from the command line.

    Furthermore, it is rare that any commercial software package will ever require a user to interact with the command line. Batch files are able to accomplish their tasks through a simple double click, nothing more is required. What difference could there possily be in running a batch script throught a command prompt instead of directly invoking the file via a double click?

     

    Secondly, regarding batch files and CScript; they do not relate in any way. A direct quote from the link you have provided, Townsbg, states:
    Windows Script Host [CScript] supports scripts written in VBScript or JScript.
    This does not include batch files. Batch files and CScript are two very different things that do not relate in anyway. The existance of CScript.exe does not assist the execution of batch files whatsoever.


     

    Alright. Back to you, Jerry,

    I've examined both scripts. They are syntaxically correct -- it's not a syntax error that is the problem. However, I've managed to track down the offending line that produces the error you've mentioned above in the OP. And this bad line is line 26 in the second batch file (find_java.bat). 'Android.bat' is not directly resonsible for the error.

    Bad line 26 in second .bat file preview:
    Code:
    for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
    The purpose of this line is to call an executable file named 'find_java.exe', which should be in the same directory in which 'find_java.bat' resides in, and stores the executable's output into a variable (named "java_exe").

    In saying this, I think the error message you recieve is actually
    Code:
    '"d:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an 
    internal or external command, operable program or batch file.
    rather than
    Code:
    '"d:\dev\android\sdk\tools\lib\\find_java.bat" -s' is not recognized as an 
    internal or external command, operable program or batch file.
    Can you confirm this?

    In addition to confirming the above, does a file named 'find_java.exe' exist in the lib folder (alongside 'find_java.bat')? If so, could you open a command window at the 'lib' directory and run the command "find_java.exe" with an s switch.

    e.g.
    Code:
    cd /d "d:\dev\android\sdk\tools\lib"
    find_java.exe -s
    What is the output you get of this?

     




     
      My Computer


  6. Posts : 1,519
    Windows 7 Ultimate 64-bit, Windows 8.1 64-bit, Mac OS X 10.10, Linux Mint 17, Windows 10 Pro TP
       #6

    Using 2 backslashes \\ in a batch file [.bat] never worked for me.
      My Computer


  7. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #7

    Hey Berton,

    Berton said:
    Using 2 backslashes \\ in a batch file [.bat] never worked for me.
    It should work.

    The command prompt is very case and slash direction insensitive. "c://\wIndOWs\\\/sYsTEM32////\\" is a valid path for all the command line cares.

    A bit of trivia: There is an exception though. A useful command for iterating through paths requires correct path names to be passed to work properly. I challange you to find this command. Or provide another example of when correct path name input is compulsory within the command prompt/batch file.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:25.
Find Us