[CLARIFIED] Executing command via FOR results in not recognized
Posted: 28 Sep 2022 05:25
This works as expected:
Results:
It seems that FOR tries to explicitly run command ' ' (nothing).
This is no problem at all in normal batch context or command line context, but within FOR it produces this error.
For my application I have already found another solution.
I'm just curious and eager to understand this behavior of FOR.
If someone could shed some light on this, I'd be very grateful.
Code: Select all
for /f "tokens=1,* delims=," %b in ("call,dir") do %~b %~c
However, the following gives an error:C:\Users\xxx>call dir
Volume in drive C is System
Volume Serial Number is 00E1-E8B3
Directory of...
(dir listing)
Code: Select all
for /f "tokens=1,* delims=," %b in (" ,dir") do %~b %~c
I don't understand why FOR, which I know runs in its own cmd /c context, has a problem with executing ' ' (nothing).C:\Users\xxx> dir
' ' is not recognized as an internal or external command,
operable program or batch file.
It seems that FOR tries to explicitly run command ' ' (nothing).
This is no problem at all in normal batch context or command line context, but within FOR it produces this error.
For my application I have already found another solution.
I'm just curious and eager to understand this behavior of FOR.
If someone could shed some light on this, I'd be very grateful.