Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: unable to launch executable from within .bat file

21 Nov 2014   #1
jerryford

Windows 7 Ultimate x64
 
 
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 System SpecsSystem Spec
.
22 Nov 2014   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
22 Nov 2014   #3
jerryford

Windows 7 Ultimate x64
 
 

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.


Attached Files
File Type: zip bad_batch_files.zip (3.1 KB, 2 views)
My System SpecsSystem Spec
.

22 Nov 2014   #4
townsbg

Windows 7 pro 64-bit
 
 

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 System SpecsSystem Spec
22 Nov 2014   #5
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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

Quote   Quote: Originally Posted by townsbg View Post
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...

Quote   Quote: Originally Posted by jerryford View Post
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:
Quote:
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 System SpecsSystem Spec
22 Nov 2014   #6
Berton

Windows 7 Ultimate 64-bit, Windows 8.1 64-bit, Mac OS X 10.10, Linux Mint 17, Windows 10 Pro TP
 
 

Using 2 backslashes \\ in a batch file [.bat] never worked for me.
My System SpecsSystem Spec
22 Nov 2014   #7
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hey Berton,

Quote   Quote: Originally Posted by Berton View Post
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 System SpecsSystem Spec
Reply

 unable to launch executable from within .bat file




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
corrupted executable file
Hi All AVG found an corrupted executable file c:\Windows\SysWOW64\mfc45.dat. I delete it from the virus vault and it returns. AVG Tech help wanted to exclude it from the search which of course just ignores it not delete it. They said that they could not delete it because it was a windows file. I...
System Security
BSOD. Unable to launch normally.
Hi, I have been getting the BSOD 0x00000050. I run a windows 7 64 bit operating system. I'm not the greatest with computer bugs and would love to get some help. It has be doing this for awhile now every time i restart but this time I can't start even after trying repeatedly. I looked into it as...
BSOD Help and Support
How to make Executable file? (.exe)
i wonder how to make Executable files? well i actually found a program called iexpress.exe but I'm stuck in some point do idea what to do.. http://oi48.tinypic.com/wqm1x.png
Software
Unable to launch any apps (I guess .exe)
My laptop (Sony Vaio / Win 7 Pro 64 bit) began playing up a couple of months ago, occasionally clicking on an icon (eg Firefox, Outlook...) in the taskbar (or from the start menu as well) failed to launch the program. The 'cursor wheel' would spin but then a few seconds later...nothing. A reboot...
Software
Executable File Size Changed after Burned to CD
I used Windows built-in CD burning to burn the CD, and selected the 2nd option, the "Mastered" option where "files can't be edited or removed after burning". I am just wondering, is this normal, there is an addition of 8MB on the file burned into the CD. I tried installing Roxio Creator, and it...
General Discussion
Borderlands unable to launch
I have Borderlands for PC which I purchased NOT from Steam. It worked a couple months ago but I reformatted my PC and now it does not launch after installation. Installation works fine and I tried reinstalling it a few times but it still will not launch when I try to launch it. It just shows that...
Gaming


Our Sites

Site Links

About Us

Find 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 13:28.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App