Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8154007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:12:14+00:00 2026-06-06T16:12:14+00:00

I have this in a batch file called find_java.bat: @echo off for /f delims=

  • 0

I have this in a batch file called find_java.bat:

@echo off
for /f "delims=" %%a in ('C:\Programming\Android\android-sdk\tools\lib\find_java.exe') do (set java_exe=%%a)

The problem is that when I run this batch file I get:

'C:\Programming\Android\android-sdk\tools\lib\find_java.exe' is not recognized as an internal or external command, operable program or batch file.

However when the batch file contains just:

@echo off
C:\Programming\Android\android-sdk\tools\lib\find_java.exe

it executes the command just fine.

I’m new to writing batch files, but looking at online examples this should work…

Edit:
Sorry for revisiting this so late.

I found the solution. It had something to do with ComSpec for reasons I still don’t quite understand. My ComSpec was

%SystemRoot%\system32\cmd.exe;

I went into the registry and changed

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\ComSpec

from

%SystemRoot%\system32\cmd.exe;

to

C:\Windows\system32\cmd.exe

then logged out and back in and magically it worked. %SystemRoot% was C:\Windows, all the other system variables use it, and

@echo off
for /f "delims=" %%a in ('"C:\Programming\Android\android-sdk\tools\lib\find_java.exe"') do (set java_exe=%%a)

worked perfectly, so I honestly don’t understand but see Command Line FOR /F Fails to possibly make more sense of it than I did.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:12:17+00:00Added an answer on June 6, 2026 at 4:12 pm

    Normally these problems are solved by enclosing the command in double quotes.

    @echo off
    for /f "delims=" %%a in ('"C:\Programming\Android\android-sdk\tools\lib\find_java.exe"') do (set java_exe=%%a)
    

    But I don’t see anything in your command that would require quotes.

    I haven’t a clue why it is not working, but the FOR /F statement is attempting to execute the command in a new CMD shell.

    Try to run the following batch and see if it runs the command OK. This is the command that the FOR statement is actually attempting to run:

    @echo off
    %comspec% /c C:\Programming\Android\android-sdk\tools\lib\find_java.exe
    

    If that runs OK, then I am completely stumped. If it fails, then figuring out why should also help diagnose why the FOR /F command is failing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a batch script that looks like this: Test.bat @echo off :: Starts
I have a batch file, 'buildAll.bat', that builds a set of projects. It will
I have this simple little batch file program that I wrote but it fails
I have this batch file which needs to do some stuff in a folder.
i have a batch(backup.bat)file.in that i have written a command to create a backup
Could anyone help me out, I have a batch file find.bat which has a
For example, suppose I have a batch file called 'test.cmd' and it simply contains:
I would like to have a non-modal alert box called form a batch file.
Hey I have this little batch file that is supposed to compare the timestamps
I have this batch that needs to run that the user has to execute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.