真巧自用的一个BAT挂载WebDAV
[Bash shell] 纯文本查看 复制代码 @echo off&setlocal enabledelayedexpansion
mode con lines=20
title 磁盘管理_V20240716
color 2
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
:start
cls
color 0a
echo *********************************************
echo * *
echo * 请选择要执行的操作: *
echo * *
echo * 1、挂载磁盘 *
echo * 2、卸载磁盘 *
echo * 3、删除配置 *
echo * *
echo *********************************************
set /p choice=请输入数字后按回车健确认:
if "%choice%"=="1" (
set remote=test
call :exist
) else if "%choice%"=="2" (
call :taskkill
) else if "%choice%"=="3" (
call :delete
) else (
echo 输入错误,请重试。
timeout /t 2 >nul
goto :start
)
pause&goto :start
:exist
if exist "%~dp0rclone.conf" (
call :taskkill
call :login
) else (
call :conf
call :taskkill
call :login
)
goto :eof
:delete
del /q "%~dp0rclone.conf"
goto :eof
:conf
echo 请输入用户名:
set /p name=
echo.请输入密码:
for /F %%A in ('powershell -command "$pwd = read-host -assecurestring; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd); [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"') do SET "password=%%A"
for /f "delims=" %%a in ('"%~dp0rclone" obscure %password%') do set "encrypted_password=%%a"
echo [%remote%]>"%~dp0rclone.conf"
echo type = webdav>>"%~dp0rclone.conf"
echo url = http://192.168.123.2:6888/>>"%~dp0rclone.conf"
echo vendor = other>>"%~dp0rclone.conf"
echo user = %name%>>"%~dp0rclone.conf"
echo pass = %encrypted_password%>>"%~dp0rclone.conf"
goto :eof
:login
echo.CreateObject("WScript.Shell").Run """%~dp0rclone"" mount %remote%:/ * --volname %remote% --dir-cache-time 5 --log-file ""%~dp0log\%remote%.txt"" --file-perms=0777 --transfers=8 --vfs-cache-mode full --cache-dir d:\\temp --vfs-cache-max-size 200G --vfs-cache-max-size off --vfs-cache-max-age 1h0m0s --no-check-certificate",0,true>"%~dp0hide.vbs"
md "%~dp0log">nul2 >nul
start "" "%~dp0hide.vbs"
echo 磁盘已加载!
timeout /t 5 >nul
del /q "%~dp0hide.vbs"
attrib +H d:\temp
goto :eof
:taskkill
taskkill /IM rclone.exe /F >nul2 >nul
echo 磁盘已卸载!
goto :eof
|