Skip to content

通过webdav打包并发送文件

bat
@echo off
chcp 65001
set password="123456"
"C:\Program Files\WinRAR\Rar.exe" a "%~n1.rar.tmp" "%~nx1" -p%password%

set filepath_tobe_send="%~n1.rar.tmp"
set dir_tobe_send="/share/dev/%~n1.rar"

set url="davs://user:pass@192.168.88.40:47053/share/"
set cert="60:0f:a3:d3:df:62:3f:19:07:ad:2d:59:21:c4:74:1e:61:54:90:3c:9b:39:26:fa:70:b3:f6:f7:d6:8b:67:00"

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /ini=nul ^
  /command ^
    "open "%url%" -certificate="%cert%"" ^
    "put "%filepath_tobe_send%" "%dir_tobe_send%"" ^
    "exit"
del "%~n1.rar.tmp"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Released under the MIT License.