When mounting using --network-mode
, a drive letter.is required, even when a UNC path is specified.
For example, rclone mount box: \\rclone\box
will still mount it as drive Z:, and the files in it are not accessible via the UNC path \\rclone\box
.
It's possible to avoid mounting to drive letters when not using --network-mode
. But File Explorer tends to analyze the content type before opening a new folder on a local drive, which could hang Explorer when I'm opening a folder full of picture/video files in a drive mounted without --network-mode
.
WinFsp comes with a sample in-memory file system, with a UNC path \\memfs64\share
that can actually be accessed by other programs. It should be mapped to a network drive before use to avoid "bad network path" error, but you can also just use net use \\memfs64\share
to activate it without assigning a drive letter.
Then I found the WinFsp documentation about WinFsp Service Architecture.
I tried to manually register rclone.exe as a service controlled by WinFsp Launcher, by creating a registry key as follows:
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\rclone]
"Executable"="path-to-rclone\\rclone.exe"
"CommandLine"="mount box: %2 --network-mode --config path-to-config-file\\rclone.conf --fuse-flag --VolumePrefix=%1"
"Security"="D:P(A;;RPWPLC;;;WD)"
"JobControl"=dword:00000001
Then, when I try to map \\rclone\box
as a network drive or use net use \\rclone\box
, rclone will be launched as local system (so the --config
path is necessary). %1
will be replaced by the UNC path "\rclone\box"
but with single backslash. %2
will be replaced by the specified drive letter, or an empty string ""
if no letter is specified. After that, I can finally access mapped files via the UNC path \\rclone\box
.
In fact, now every UNC paths starting with \\rclone\
will be redirected to the rclone instance. The "server" part must be the registry key name (rclone), but the "share" part can be anything. As for now, different "shares" on \\rclone\
maps to the same box:
remote.
There's still a problem, though. Providing an empty string as the mount point still makes rclone assign a free drive letter automatically. An option to prevent assigning drive letters when mount point is an empty string and a UNC path is provided would be appreciated.