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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:47:43+00:00 2026-06-01T18:47:43+00:00

Batch contents: FOR /F tokens=1,* %%i IN (list.txt) DO ( cd %%j Echo %CD%

  • 0

Batch contents:

FOR /F "tokens=1,*" %%i IN (list.txt) DO (
    cd "%%j"
    Echo %CD%
    pause
)

Execution run:

C:\Dwn>tmp1.bat

C:\Dwn>FOR /F "tokens=1,*" %i IN (list.txt) DO (
cd "%j"
 Echo C:\Dwn
 pause
)

C:\Dwn>(
cd "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Administrative Tools"
 Echo C:\Dwn
 pause
)
The system cannot find the path specified.
C:\Dwn
Press any key to continue . . .

How come the system cannot find the path specified? If I copy that cd command and execute it by itself it works fine.

  • 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-01T18:47:44+00:00Added an answer on June 1, 2026 at 6:47 pm

    It fails because the value of %%j contains %APPDATA%. The value of %APPDATA% will not get expanded when you expand %%j because environment variable expansion occurs before FOR variable expansion.

    The fix is to use call cd "%%j" instead. The CALL will cause the command to go through an extra level of %VAR% expansion, which is exactly what you want.

    You also have a problem in that you use echo %CD% within the same DO code block. It will echo the value of the current directory before your change because the value of %CD% is expanded when the entire FOR statement is parsed. You could fix this by using call echo %CD%, or by enabling delayed expansion with SETLOCAL EnableDelayedExpansion and using echo !CD!. But the simplest fix is to simply use cd; the CD command without any arguments will print the current directory to the screen.

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

Sidebar

Related Questions

The batch file has only two lines: c:\program.exe ... pause but pause does't run
I have this little batch script: SET @var = GREG ECHO %@var% PAUSE When
I'm using Windows and have a batch file (contents attached below) where I'm building
In batch script, I can run an R script with the following syntax: Rterm.exe
I want to write a batch file that will take the contents of a
How do I (recursively) search all file contents in Windows 7? I am using
I am putting the finishing touches to a batch script that transfers the contents
Duplicate data removal using Perl called within via a batch file within Windows A
I currently have a batch file with the following contents to generate the Liquibase
I wrote a small batch file to rar all contents in all subfolders within

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.