Automation 对于/f运行powershell转义字符

Automation 对于/f运行powershell转义字符,automation,cmd,Automation,Cmd,当我在cmd提示符下运行以下命令时,它工作正常 pushd "C:\Converter" for /f "delims=" %g in ('dir "C:\Toconvert" /b /s /ad') do (powershell .\BatchConvert.ps1 "%g" 10) popd 它成功地执行了命令。 这是输出: C:\Converter>(powershell .\BatchConvert.ps1 "C:\Toconvert\Prego!PDF" 10 ) 当我尝试在

当我在cmd提示符下运行以下命令时,它工作正常

pushd "C:\Converter"
for /f "delims=" %g in ('dir "C:\Toconvert" /b /s /ad') do (powershell .\BatchConvert.ps1 "%g" 10)
popd
它成功地执行了命令。 这是输出:

C:\Converter>(powershell .\BatchConvert.ps1 "C:\Toconvert\Prego!PDF" 10 )
当我尝试在.bat文件中运行相同的命令时,失败了。使用cmd line运行bat文件,我发现它生成的是:

C:\Converter>for /f "delims=" \Toconvert" /b /s /ad') do (powershell .\BatchConvert.ps1 "g" 10)

为什么在('dir'C:"在括号之前,为什么它会在do命令中删除%呢?如何转义字符以使其作为.bat工作?

%在批处理文件中使用时必须加倍为%%-dbenham 5月17日'13日12:39

%
在批处理文件中使用时必须加倍为
%
!我的头一直在桌子上敲打着t正在向谷歌咨询问题所在。谢谢!