開頭:我爲我的糟糕英語和拼寫錯誤表示歉意,我是這個論壇的新成員,如果我做錯了某些事情,可以隨意點它出來,我剛開始編程,所以我就是所謂的菜鳥;)批處理文件:在IF子句中使用以前的輸出
我有一個非常具體的問題。我正在嘗試編寫批處理文件來爲遊戲安裝服務器,並且我必須下載三個文件。爲此,我使用bitsadmin
命令,但有時下載失敗,我希望批處理刪除這個不良文件,並在失敗時再次下載。
下面是使用代碼片段之一:
rem Download SteamCMD
:cmd_not_exist
>>%directory%RustServer\temp\log1.txt bitsadmin /transfer Download_SteamCMD
/download /priority normal https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip %directory%SteamCMD\steamcmd.zip
set "do_cmd_exist="
for /F "skip=8 delims=" %%i in (>>%directory%RustServer\temp\log1.txt) do if not defined do_cmd_exist set "do_cmd_exist=%%i"
if "%do_cmd_exist%" == "Transfer complete." (
goto cmd_exist
) else (
del %directory%SteamCMD\steamcmd.zip
del %directory%RustServer\temp\log1.txt
goto cmd_not_exist
)
:cmd_exist
(不含自由行它看起來真的搞砸)
所以我嘗試寫日誌的命令,並檢查登錄以查看它是否表示傳輸完成。但它不起作用。
我願意接受任何建議,但我不喜歡使用第三方合作伙伴計劃。
要查看所有的代碼 - 我把它放在我的Pastebin頁面上。 http://pastebin.com/w7wLsvkF
感謝您抽出寶貴的時間只是閱讀本...的xD
非常感謝編輯我的文章! @Deepend(我不知道它是否以這種方式工作) – XaverXor
不用擔心,也不需要感謝我。希望你能得到答案。歡迎來到SO – Deepend