【发布时间】:2011-10-04 15:55:25
【问题描述】:
基本上,我想将最新版本的 MSI 从服务器复制到我的本地计算机。我正在尝试遍历一个文件并抓取包含要抓取的最新版本的 MSI 的第一行。我并不完全熟悉 for 循环和批处理文件中的 if 语句的怪异之处。这是我找到第一行后不断循环的代码:
cd %~dp0
mkdir "c:\MyApp\QA\msi"
rem Determine what folder is the latest version of QA
setlocal enabledelayedexpansion
dir /b /o-n "\\my-server\folder\another_folder\5.0.*" > output.txt
SET /a counter=1
SET version=""
for /f "usebackq delims=" %%a in (output.txt) do (
if "counter"==1 goto install (
xcopy "\\my-server\folder\another_folder\%%a\myinstaller.msi" "c:\MyApp\QA\msi\myinstaller.msi" /y
)
SET /a counter+=1
)
goto exit
:exit
PAUSE
【问题讨论】:
标签: windows batch-file if-statement for-loop