問一下會寫bat批次檔的前輩們
不知道我哪邊寫錯了,
每個獨立抓出來都能執行,
但合起來還沒進入迴圈就掛了,
最前面就掛得莫名其妙,
後續全部都卡住...
有前輩可以為我指點迷津嗎?
@echo off
:: 切換為UTF-8
chcp 65001
:: 延遲變數展開, 這樣就可在回圈內取得變數的即時內容(取值改用 !var! )
setlocal EnableDelayedExpansion
set mydate=%date:~3,10%
set mydate=%mydate:/=%
echo 準備進入迴圈
FOR /F %%i IN (badpasswd.txt) DO (
echo 已進入迴圈: %%i
echo 設定myTime
set myTime=%time%
set myTime=%myTime::=%
echo 設定logfile
set logfile=%mydate%_%myTime%_%%i.txt
set logfile=%logfile:^==%
echo 顯示設定結果
echo TestFileName: %logfile%
echo TestFileName: !logfile!
pause
::(後續忽略)
)
執行結果
Active code page: 65001
準備進入迴圈
The syntax of the command is incorrect.