信息: assets.txt包含一个我可以通过网络连接到的cpu名称列表。
我需要将这个新的.exe复制到200+计算机上,并认为我可以使用c$ admin共享。这是唯一的办法,我可以做到这一点,而不去工作站单独或远程处理一个接一个。
这个脚本在没有“if存在”的情况下工作,但是在尝试复制之前,我需要检查目录是否存在。我不明白为什么不起作用。我也使用我的域管理帐户运行这个脚本。
@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?
提前谢谢大家抽出时间。
发布于 2014-02-14 15:15:19
副本上的错误将设置错误级别,您可以编写自定义错误消息。
copy "\\server\my dir\management\it\software\Intouch Upgrade\Intouch2ca.exe" "\\%%A\C$\Program Files\Intouch2\" >nul 2>&1
if errorlevel 1 >> errors.txt echo "Error in %%A"https://stackoverflow.com/questions/21782742
复制相似问题