Batch File: FOR /F doesn't work if path has spaces

后端 未结 3 2009
粉色の甜心
粉色の甜心 2020-12-06 16:54

This is the problem I\'m having:

@ECHO OFF

REM If this batch file is run in the same directory as \"command.exe\" then the
REM following line will work.
FOR         


        
3条回答
  •  囚心锁ツ
    2020-12-06 17:21

    The call trick of Andriy M is clever and works fine, but I tried to understand the problem here.

    This problem is caused by the cmd.exe, as you can read at cmd /help

    ....
    the first and the last quote will be removed, when there are not exactly two quotes in the line.
    ...

    So there is also another solution with simply adding two extra quotes

    FOR /F "usebackq=" %%A IN (`""C:\Folder Space\myCmd.exe" "Param space""`) DO (
        ECHO %%A
    )
    

提交回复
热议问题