Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理脚本结束括号问题_Batch File - Fatal编程技术网

Batch file 批处理脚本结束括号问题

Batch file 批处理脚本结束括号问题,batch-file,Batch File,我使用以下批处理脚本将提供的文本替换为其他文本 @echo off setlocal call :FindReplace %1 %2 %3 exit /b :FindReplace <findstr> <replstr> <file> set tmp="%temp%\tmp.txt" If not exist %temp%\_.vbs call :MakeReplace for /f "tokens=*" %%a in ('dir "%3" /s /

我使用以下批处理脚本将提供的文本替换为其他文本

@echo off
setlocal


call :FindReplace %1 %2 %3

exit /b 

:FindReplace <findstr> <replstr> <file>
set tmp="%temp%\tmp.txt"
If not exist %temp%\_.vbs call :MakeReplace
for /f "tokens=*" %%a in ('dir "%3" /s /b /a-d /on') do (
  for /f "usebackq" %%b in (`Findstr /mic:"%~1" "%%a"`) do (
    echo(&Echo Replacing "%~1" with "%~2" in file %%~nxa
    <%%a cscript //nologo %temp%\_.vbs "%~1" "%~2">%tmp%
    if exist %tmp% move /Y %tmp% "%%~dpnxa">nul
  )
)
del %temp%\_.vbs
exit /b

:MakeReplace
>%temp%\_.vbs echo with Wscript
>>%temp%\_.vbs echo set args=.arguments
>>%temp%\_.vbs echo .StdOut.Write _
>>%temp%\_.vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1,-1,1)
>>%temp%\_.vbs echo end with
由于路径中的“'),我在控制台中得到以下内容

\Apache was unexpected at this time.

请帮我避开“')。

这是一个问题:将
%3”
更改为
“%~3”


这就是为什么路径字符串中的字符不受保护,因为%3已被双引号引用。

请使用powershell。
\Apache was unexpected at this time.