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 7635447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:25:42+00:00 2026-05-31T07:25:42+00:00

I have a DOS build script which works on one Windows Server 2008 R2

  • 0

I have a DOS build script which works on one Windows Server 2008 R2 but not another. To see the symptoms on the broken machine entering either of the following at the command line:

for /f %X in ('dir /b *.txt') do @echo %X
for /f "usebackq" %X in (`dir /b *.txt`) do @echo %X

gives: “‘dir /b *.txt’ is not recognised as an internal or external command.” while e.g.

for %X in (*.txt) do @echo %X

works fine, so the /f is not being obeyed properly. I don’t believe this is the Command Extensions themselves (starting cmd /x shows the same behaviour; running them inside cmd /y on the problem server gives the normal “/f was unexpected at this time”). I have also checked the command extensions registry keys and tried “setlocal enableextensions” in the batch files.

I don’t think it’s relevant but differences between the servers are that the failing one is physical; its CPU doesn’t have VT extensions; does have McAfee installed. As far as I know they were installed the same way though at different times.

Does anyone have any suggestions? I am stuck!

  • 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-05-31T07:25:43+00:00Added an answer on May 31, 2026 at 7:25 am

    Check the COMSPEC environment variable in on the machine where it doesn’t work, i.e. do echo %COMSPEC% and see what it contains (it should be %windir%\system32\cmd.exe or comparable).

    Long Story:

    You’re detailed question ruled out all other potential possibilities (like the need to use %%X instead of %X inside batch files, as compared to the command line), like fiddling with setlocal enableextensions (or comparable switches, registry entries, etc.). And by the way, the error message would not fit.

    If you get the error message “…is not recognised as an internal or external command” it is, that CMD.EXE cannot find the command you’re trying to execute. Since “dir” is an internal command “this should never happen”, of course.

    I was able to reproduce your error doing the following:

    1. Start CMD.EXE
    2. Enter the following SET ComSpec=DoesNotExist
    3. Enter the following CMD.EXE, i.e. start another, nested, CMD.EXE session. This step is required, in a running CMD.EXE session, the change to ComSpec seems to go unnoticed.
    4. In the new CMD.EXE session enter your command (e.g. for /F %x in ('dir /b') do @echo%x), you should get the error you see. Note if you just enter dir it will still work, so you have to have that “indirect” execution via, e.g., a for loop. Funny.

    Note that this was all done to reproduce what you are seeing, the reasons exact environmental or setup conditions that lead to this behavior on your system might be different, however the fact that the ComSpec environment variable refers to something other than CMD.EXE should be the same.

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

Sidebar

Related Questions

I have a nightly build DOS batch script that invokes devenv.exe to build a
I have a home-grown automated build script in the form of a DOS batch
I have a DOS batch script that invokes a java application which interacts with
I have a python (2.5.4) script which I run in cygwin (in a DOS
The same way DOS morphed into Windows? We seem to have ended up supporting
I have a pawnshop CRUD app written 20 years ago with INFORMIX-SQL/SE (DOS) which
On windows systems, certain dos commands don't have executables that can be explicitly called
I have a DOS command which outputs as follows (just an example containing 3
I have a project with a post build event: copy $(ProjectDir)DbVerse\Lunaverse.DbVerse.*.exe $(TargetDir) It works
I have not worked with DOS much as there were always shell scripting in

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.