INFO:assets.txt包含一個我可以通過網絡連接的cpu名稱列表。BATCH FILE - IF Exists&Output Error
我需要將這個新的.exe複製到超過200多臺計算機上,並且認爲我可以使用c $ admin共享。這是我能夠做到這一點的唯一方式,無需單獨進入工作站或逐個進行遠程處理。
此腳本沒有'if exists',但是我需要在嘗試複製之前檢查目錄是否存在。我不明白爲什麼它不起作用。我也使用我的域管理帳戶運行此腳本。
@echo off
REM Pull Computer Asset Tags from file
for /F "tokens=*" %%A in (assets.txt) do (
echo Start Processing %%A
REM Temporarily set file path for existence check
set file=\\%%A\C$\Program Files\Intouch2\Intouch2ca.exe
if EXIST "%file%" (
REM Rename old .exe
ren "\\%%A\C$\Program Files\Intouch2\Intouch2ca.exe" "Intouch2ca.bak"
REM copy new .exe from server to cpu asset
xcopy "\\server\my dir\management\it\software\Intouch Upgrade\Intouch2ca.exe" "\\%%A\C$\Program Files\Intouch2\" /Y
echo END Processing %%A
echo.
echo ------------------------------------------------------------
echo.
)
)
我也一直沒能得到錯誤輸出到日誌文件。 我試過這個,但它不是我想要的。
xcopy "\\server\my dir\management\it\software\Intouch Upgrade\Intouch2ca.exe" "\\%%A\C$\Program Files\Intouch2\" /Y 1>>errors.log 2>&1
我怎麼能相當,高達所以只顯示錯誤,並列出了%%A
當出現錯誤?
非常感謝大家的時間。
錯誤消息來自哪裏?它有什麼錯誤? – foxidrive
我希望能夠從文件副本中捕獲錯誤。你的解決方案工作得很好。謝謝! – Drew