【自用】使用Rclone把webdav挂载为电脑本地硬盘
鱼游上了岸
2024年06月08日 00:47

参考了 CV21803909  CV26300078 这两篇,并在两篇基础上稍作修改,仅供自己使用,做个记录 免得以后忘了

安装前置

需要用到的软件包括Rclone和WinFsp。 (一定要先安装好)

下载地址:

https://rclone.org/downloads/

https://winfsp.dev/ 

步骤

将Rclone复制到任意目录。(注:要选择英文目录,且目录中不要有空格,例如不要安装到Program Files文件夹里,不然后面设置开机启动时会遇到坑)

1.打开cmd,

2进入到放置Rclone的目录, 在cmd里输入 cd /d D:\rclone-v1.66.0-windows-amd64  (加黑部分改成自己的文件夹路径)

输入rclone.exe config

开始添加或修改你的webdav服务器,假设这里你添加的服务器name叫webdav。按照指令提示进行即可。具体如下

e) Edit existing remote

n) New remote

d) Delete remote

r) Rename remote

c) Copy remote

s) Set configuration password

q) Quit config

e/n/d/r/c/s/q>

# 这里新建一个配置文件 所以输入n

 > n

Enter name for new remote.

name>

# 这里的name就是一会挂载上去的硬盘的默认名称

> webdav

...

46 / WebDAV

  \ (webdav)

...

Storage>

# 这里是输入你的远程磁盘的类型 我这里webdav是46 所以输入46

> 46

Option url.

URL of http host to connect to.

E.g. https://example.com.

Enter a value.

url>

# 这里就要输入你的远程磁盘的地址了

> http://192.168.0.111:8080

Option vendor.

Name of the WebDAV site/service/software you are using.

Choose a number from below, or type in your own value.

Press Enter to leave empty.

 1 / Nextcloud

  \ (nextcloud)

 2 / Owncloud

  \ (owncloud)

 3 / Sharepoint Online, authenticated by Microsoft account

  \ (sharepoint)

 4 / Sharepoint with NTLM authentication, usually self-hosted or on-premises

  \ (sharepoint-ntlm)

 5 / Other site/service or software

  \ (other)

vendor>

# 这里是预设了几种webdav软件的配置 因为我这个是自己搭的 所以选other

> 5

# 下面是你自己的用户信息 你的webdav服务器连接的账号密码 我就不赘述了

Option user.

User name.

In case NTLM authentication is used, the username should be in the format 'Domain\User'.

Enter a value. Press Enter to leave empty.

user>

Option pass.

Password.

Choose an alternative below. Press Enter for the default (n).

y) Yes, type in my own password

g) Generate random password

n) No, leave this optional password blank (default)

y/g/n>

# 我已经有密码了 输入我自己的密码

> y

# 密码要重复两次

Enter the password:

password:

Confirm the password:

password:

Option bearer_token.

Bearer token instead of user/pass (e.g. a Macaroon).

Enter a value. Press Enter to leave empty.

bearer_token>

# 这玩意我并没看懂是啥 按理说应该是个令牌 但是不管你是直接回车下一步还是输了东西了 都不影响后面的使用

Edit advanced config?

y) Yes

n) No (default)

y/n>

# 这里没必要再搞高级设置了 直接n

> n

# 下面程序会给你看你刚才的设置

Configuration complete.

Options:

- type: webdav

- url: http://192.168.0.233:8899

- vendor: other

- user: oranflo

- pass: *** ENCRYPTED ***

- bearer_token: ...

Keep this "webdav" remote?

y) Yes this is OK (default)

e) Edit this remote

d) Delete this remote

y/e/d>

# 没问题的话就设置完了 选y

> y

Current remotes:

Name         Type

====         ====

webdav        webdav

e) Edit existing remote

n) New remote

d) Delete remote

r) Rename remote

c) Copy remote

s) Set configuration password

q) Quit config

e/n/d/r/c/s/q>

# 这里已经看到你的配置了 可以退出设置了 选q

> q 

配置完成后可以正式启动程序了,输入命令  将xiaohua挂载到Y盘:

rclone.exe mount xiaohua:/ y: --vfs-cache-mode full 

 (加粗部分按照自己的要求修改)

下面你应该会看到:

The service rclone has been started.

也就是说明你挂载成功了,回资源管理器检查下是不是多了一个本地磁盘 

注意:此时cmd窗口不能关闭,否则rclone就会停止运行

下面教你如何设置开机静默运行rclone

==========================================================

将Rclone设置为开机自启动

1 在rclone.exe同级目录新建一个rclone.bat文件,内容为:rclone.exe mount xiaohua:/ y: --vfs-cache-mode full 

2 在rclone.exe同级目录新建一个rclone.vbs文件,内容为:

CreateObject("WScript.Shell").Run "cmd /c D:\rclone-v1.66.0-windows-amd64/rclone.bat",0

注:如果黑色加粗的relone文件夹路径里有空格,则此vbs文件无法运行

3 将rclone.vbs创建快捷方式,并将该快捷方式放入到windows启动目录(C:\%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup)