標籤:client data ping highlight 工具 ken 成功 psexec error
關於Windows的推包升級可以用自動化工具,但如果機器數量不多,使用指令碼效率更高,這裡使用到PsExec.exe工具。
結構:
initServer.bat
work.bat
PsExec.exe
files(要推的檔案)
resSuccess.log(執行成功的日誌)
resFaild.log(執行失敗的日誌)
init.bat是把serverPWD.txt 裡面目標ip和密碼傳到work.bat。
initServer.bat
echo -----start at:%data% %time%----->resSuccess.logecho -----start at:%data% %time%----->resFaild.logfor /F “tokens=1,2 delims=:” %%i in(serverPWD.txt)do(call work.bat %%i %%j)echo -----end at:%data% %time%----->resSuccess.logecho -----end at:%data% %time%----->resFaild.log
work.bat的作用是把files裡的檔案拷貝到目標機器上,然後執行上面的指令碼。
work.bat
set ip=%1%set pwd=%2%set files=filesnet use \\%ip% “%pwd%” /user:”administrator”if %errorlevel% EQU 0 (xcopy /S /E /Y %files% \\%ip%\C$ping 127.0.0.1 –n 2start cmd /c PsExec.exe \\%ip% -u administrator –p %pwd% -w C:\client C:\client\run.batnet use \\%ip%\IPC$ /delecho %ip%>> resSuccess.log)else(echo %ip%>> resFaild.log)
Windows推包指令碼