OneKuma

OneKuma's Blog

One Lonely Kuma.
github
bilibili
twitter

Mounting WebDAV on Windows

Continuing from the previous article Playing around with Aliyun Drive + AList + Rclone + AnimePaste, let's continue tinkering.

In the previous article, we used rclone to mount WebDAV to a local directory, and we had to manually run a script in the Terminal, which couldn't be closed. Now, we want to make it automatically start in the background when the computer starts up.

Update 1: After using it for a week, the experience was not very good. The local directory mounted by rclone was very unstable. It often froze and remained unresponsive for a long time, making it difficult to automatically recover. The mount point could not be occupied due to improper shutdown or abnormal termination of rclone, making it impossible to remount. After searching, I found that Windows natively has a similar implementation, for example, OneDrive uses WebDAV in the background.

Update 2: I tried using the WebDAV provided by Windows natively for a while, but it still didn't work well. There were occasional failures in automatically mounting at startup, which required manual intervention. The reason might be that AList had not started when it was mounted. Also, after mounting was just started or AList was restarted, there were occasional failures in reading files. Furthermore, when opening with VS Code, I don't know why AList would send a large number of concurrent requests, which easily caused various strange problems. Lastly, when editing text files with VS Code, there was an issue with inconsistent caching. Finally, I switched to RaiDrive now. Currently, there seems to be an issue with inconsistent caching, but it may be partly due to VS Code. Other than that, except for the fact that it has an advertisement when starting up without paying, there are no issues and it provides the best experience.

Solution 1: RaiDrive#

Official website: https://www.raidrive.com/

Download and install it. It's quite straightforward to use.

Solution 2: Native Windows Network Drive Mapping#

In File Explorer, right-click on "This PC" and select "Map network drive...".

image

Choose the drive letter you want and enter the address of your local/remote AList.

image

Enter your AList username and password.

image

The same applies to other WebDAV services.

Possible Issues#

  1. You may need to enable WebDAV in the Control Panel, located at "Control Panel" - "Programs" - "Turn Windows features on or off". The option path is shown in the following image.

image

  1. If the WebDAV in your local network uses HTTP instead of HTTPS, you may encounter the "The network name cannot be found" error. You need to open the "Registry Editor", navigate to HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters, and modify the value of the key BasicAuthLevel to 2, allowing both HTTP and HTTPS.

Solution 3: rclone + nssm#

Mount Script#

The mount script needs some modifications:

  1. Replace rclone with the absolute path;
  2. Specify the path of --config (you can check the current configuration file path with rclone config file);
  3. Mounting to a separate disk seems to be more stable than mounting to a directory?
# mount-anime.ps1

D:\bin\rclone mount "alist:/" "R:" `
  --config "C:\Users\<your system username>\AppData\Roaming\rclone\rclone.conf" `
  --header "Referer:https://www.aliyundrive.com/" `
  --vfs-cache-mode full --vfs-read-chunk-size-limit 1G --vfs-read-chunk-size 512M `
  --cache-dir "D:\.cache\rclone" --dir-cache-time 1m --buffer-size 128M `
  -o UserName="<your system username>" -o GroupName="Authenticated Users"

Note:
When running this script with nssm, it is not started from your current user, so the PATH environment variable is not available.
Also, due to the login user, there are permission issues with the mount directory. The last line of the command refers to Mount Permission (Windows), which seems to fix the permission issue I encountered.

nssm#

Download nssm, which is a Non-Sucking Service Manager for Windows.

After downloading nssm 2.24, extract the executable file and copy it to a directory in the PATH (here we use D:\bin\ as a common directory). Then, run the following command to open the nssm GUI and create a service named mount-anime.

nssm install mount-anime

Fill in the following configurations:

  • Application - Path: The absolute path of PowerShell (e.g., C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe);
  • Application - Startup directory: Any directory;
  • Application - Arguments: The absolute path of the mount startup script created in the previous article;
  • I/O: It is recommended to redirect stdout / stderr to a file for easy debugging.

After creating it, start the service in a Terminal with Administrator mode.

nssm start mount-anime
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.