Windows: No-install alternative for auto-reconnecting a WebDAV drive after reboot (guide + script)

Before anything else: check out NcDavTray first

NcDavTray by @ernolf is a purpose-built, actively maintained tool that solves this exact problem (see the announcement thread), and does it better than what’s below in almost every way: it doesn’t need admin rights (except for one optional step), it has a proper watchdog that reconnects automatically if the server drops (not just once at logon), it shows connection status in the tray, it supports file locking for Office apps - and as @ernolf pointed out, it also has a portable mode that needs no installation at all. For the vast majority of people, that’s the tool to use, full stop.

Edit: I originally framed this post around “can’t install anything,” but that’s not actually a meaningful distinction anymore since NcDavTray’s portable mode already covers that. The one case where this approach is still relevant: environments with application whitelisting (AppLocker/WDAC) that block any non-approved executable from running at all, portable or not - where only tools already built into Windows itself (Scheduled Tasks, net use) are permitted. That was my exact situation on a locked-down work PC.

One genuine difference worth mentioning: NcDavTray uses Nextcloud-specific APIs (maintenance-mode check, OCS API for the folder browser, favicon) for its nicer UX, so it’s purpose-built for Nextcloud. The plain net use / WebDAV approach below is protocol-level generic - it works against any WebDAV server, Nextcloud-based or not.

The problem

If you map your Murena cloud storage as a WebDAV network drive on Windows (e.g. via net use or “Map network drive”), you’ve probably run into this: it works fine right after you set it up, but after a restart the drive is gone, shows a red X, or you have to manually reconnect it every time.

This is not specific to Murena - it’s a long-standing, well-documented Windows WebDAV issue (see nextcloud/documentation#10207 and nextcloud/desktop#2810). The root cause: Windows’ WebClient service (which handles WebDAV) doesn’t reliably auto-start early enough at boot, and even when it does, a drive mapped in an elevated session is invisible in File Explorer.

Worth knowing: the Windows WebDAV client (WebClient service) has been officially marked as deprecated since November 2023, and is disabled by default on current Windows versions - see Microsoft’s deprecated features list. It’s not being removed imminently, but Microsoft isn’t investing in it either, which is a big part of why it behaves this inconsistently. That’s also exactly why tools like NcDavTray (using the Cloud Files API / its own connection handling) exist - they don’t depend on this aging component at all. What follows below is purely a workaround for people who, for whatever reason, are stuck using the built-in client.

I spent several days debugging this properly (including testing across genuine cold boots, with Fast Startup disabled) and ended up with a setup that has now worked reliably for over a week on two different PCs. Sharing it here in case it saves someone else the same debugging marathon, in that specific “can’t install anything” situation.

What this fixes

  • Drive reconnects automatically after every restart, with no manual steps
  • Password is never stored in plain text anywhere
  • Works around the “service needs admin rights, but the drive mapping must NOT be elevated or it’s invisible in Explorer” conflict
  • Includes a safe minimum timing gap between the two steps, found through real multi-day testing
  • Uses only tools already built into Windows - nothing to install, nothing extra to trust

Before you start

  • You’ll need a Murena app password (not your main account password): murena.io → Account Settings → Security → App Passwords
  • Use a separate app password per device - don’t reuse the same one on your phone and PC
  • Never share this password with anyone - not in a forum post, not in a chat, not with an AI assistant. If you ever do by accident, revoke it immediately and create a new one.
  • This script needs to run with administrator rights (it will prompt for UAC automatically) - if you don’t have local admin rights on the PC, this approach won’t work for you either, and NcDavTray (which only needs admin for one optional step) is worth asking your IT department about instead
  • This script is hardcoded for murena.io. For any other Nextcloud-based server (self-hosted, a different provider, etc.), just change the WSERVER value near the top of the script to your own server address - the rest works as-is, since remote.php/dav/files/... is the standard Nextcloud WebDAV path structure.
  • For non-Nextcloud WebDAV servers (e.g. a NAS, SharePoint, or a different WebDAV implementation), the underlying net use technique still applies, but the path structure itself is Nextcloud-specific - you’d need to adjust the UNC path in the script to match whatever path structure your server actually uses.

How it works (short version)

Two separate Scheduled Tasks are created:

  1. “Murena WebClient Start” - starts the Windows WebClient service a few seconds after logon, with elevated rights (the service needs this to start reliably)
  2. “Murena WebDAV Reconnect” - maps the drive ~10-15 seconds after task 1, WITHOUT elevated rights (so the drive is visible in File Explorer)

The credential is saved using net use ... /savecred, which stores it securely in Windows Credential Manager - never as plain text.

Important: there must be at least a ~10 second gap between the two tasks, otherwise the drive mapping fires before the service is actually ready and silently fails. 5s / 15s worked reliably in my testing, but depending on your network/PC you may need more (e.g. if you’re on a VPN or domain login).

One real limitation worth being upfront about: unlike NcDavTray’s watchdog, this only tries once at logon. If the server briefly goes offline or the connection drops mid-session, it won’t automatically recover until the next restart - you’d need to rerun the drive-mapping task manually. For most people, NcDavTray’s active reconnect handling is the better everyday experience if you can install it.

The script

Save this as Murena_WebDAV_Manager.bat and run it (double-click; it will ask for admin rights). It has a menu: set up from scratch, change the saved password, remove everything, or show current status.

batch

@echo off
setlocal EnableDelayedExpansion
title Murena WebDAV - Connection Manager
color 0B

:: ============================================================
::  Check for administrator rights - required to manage the
::  WebClient service and create elevated scheduled tasks
:: ============================================================
net session >nul 2>&1
if not %errorlevel%==0 (
    echo This tool requires administrator rights.
    echo Restarting with elevated permissions, please confirm the UAC prompt...
    powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
    exit /b
)

:SECURITY_NOTICE
cls
echo ================================================================
echo    IMPORTANT SECURITY NOTICE
echo ================================================================
echo.
echo  Never send your password (Murena app password) to anyone, and
echo  never paste it into a chat, AI assistant, email, message, or
echo  screenshot.
echo.
echo  If you have ever shared your password this way (e.g. while
echo  asking for help with the setup), treat it as compromised and
echo  do this RIGHT NOW:
echo.
echo    Murena.io - Account Settings - Security - App Passwords
echo    - revoke the old password and create a new one
echo.
echo  Only use this script with a fresh password that has never
echo  been shared anywhere.
echo ================================================================
echo.
pause

:MENU
cls
echo ================================================================
echo    MURENA WEBDAV - AUTOMATIC CONNECTION MANAGER (Windows)
echo ================================================================
echo.
echo    1. Set up the connection from scratch
echo    2. Change the saved password (after creating a new one on Murena.io)
echo    3. Remove the entire setup (reset to zero)
echo    4. Show current status
echo    5. Exit
echo.
set "CHOICE="
set /p CHOICE="Choose an option (1-5): "

if "%CHOICE%"=="1" goto SETUP
if "%CHOICE%"=="2" goto CHANGEPW
if "%CHOICE%"=="3" goto REMOVE
if "%CHOICE%"=="4" goto STATUS
if "%CHOICE%"=="5" exit /b
goto MENU


:: ================================================================
::  PART A - SETUP FROM SCRATCH
:: ================================================================
:SETUP
cls
echo ================================================================
echo    SETUP FROM SCRATCH
echo ================================================================
echo.
echo Note: if a previous setup with a different drive letter already
echo exists, running this again will overwrite it.
echo.
echo The username may contain a space - this is handled correctly.
echo.

set "WUSER="
set /p WUSER="Enter your Murena login username: "
if "%WUSER%"=="" (
    echo Username cannot be empty.
    pause
    goto SETUP
)

set "WSERVER=murena.io"

:DRIVELETTER
set "WDRIVE="
set /p WDRIVE="Enter the drive letter you want to use (e.g. M): "
if "%WDRIVE%"=="" goto DRIVELETTER
set "WDRIVE=%WDRIVE:~0,1%"
echo %WDRIVE%| findstr /r /i "^[a-zA-Z]$" >nul
if errorlevel 1 (
    echo Invalid letter, try again.
    goto DRIVELETTER
)
echo Drive to be used: %WDRIVE%:

echo.
echo --- Scheduled task timing ---
echo (Press Enter without a value to use the recommended value in brackets.)
echo.

set "WCDELAY="
set /p WCDELAY="Delay before starting the WebClient service, in seconds [range 5-60, recommended 5]: "
if "%WCDELAY%"=="" set "WCDELAY=5"
echo %WCDELAY%| findstr /r "^[0-9][0-9]*$" >nul
if errorlevel 1 set "WCDELAY=5"
if %WCDELAY% LSS 5 set "WCDELAY=5"
if %WCDELAY% GTR 60 set "WCDELAY=60"

set /a DISKMIN=%WCDELAY%+10
echo.
echo There must be at least a 10-second gap between the two tasks -
echo otherwise the drive mapping may be attempted before the
echo WebClient service is actually running, and the connection will
echo silently fail. This minimum was confirmed through real testing,
echo but in your environment (slower network, VPN, domain logon,
echo etc.) you may later find you need even more.
echo.
set "DISKDELAY="
set /p DISKDELAY="Delay before mapping the drive, in seconds [minimum %DISKMIN%, max 90]: "
if "%DISKDELAY%"=="" set "DISKDELAY=%DISKMIN%"
echo %DISKDELAY%| findstr /r "^[0-9][0-9]*$" >nul
if errorlevel 1 set "DISKDELAY=%DISKMIN%"
if %DISKDELAY% LSS %DISKMIN% (
    echo.
    echo The value entered is below the allowed minimum - automatically
    echo using %DISKMIN%s instead.
    set "DISKDELAY=%DISKMIN%"
)
if %DISKDELAY% GTR 90 set "DISKDELAY=90"

set /a WCMM=%WCDELAY%/60
set /a WCSS=%WCDELAY%%%60
set "WCMM=000%WCMM%"
set "WCMM=%WCMM:~-4%"
set "WCSS=0%WCSS%"
set "WCSS=%WCSS:~-2%"
set "WCFMT=%WCMM%:%WCSS%"

set /a DISKMM=%DISKDELAY%/60
set /a DISKSS=%DISKDELAY%%%60
set "DISKMM=000%DISKMM%"
set "DISKMM=%DISKMM:~-4%"
set "DISKSS=0%DISKSS%"
set "DISKSS=%DISKSS:~-2%"
set "DISKFMT=%DISKMM%:%DISKSS%"

set "UNCPATH=\\%WSERVER%@SSL\DavWWWRoot\remote.php\dav\files\%WUSER%"

echo.
echo ================================================================
echo  SUMMARY
echo ================================================================
echo   Username:          %WUSER%
echo   Server:            %WSERVER%
echo   Drive:             %WDRIVE%:
echo   Path:              %UNCPATH%
echo   Service delay:     %WCDELAY%s
echo   Drive delay:       %DISKDELAY%s
echo ================================================================
echo.
pause

echo.
echo [1/4] Starting the WebClient service...
net start WebClient >nul 2>&1

echo [2/4] Mapping the drive - enter your password when prompted...
net use %WDRIVE%: /delete >nul 2>&1
net use %WDRIVE%: "%UNCPATH%" /savecred
if not "%errorlevel%"=="0" (
    echo.
    echo ERROR: The connection failed. Check the username, password, and server address.
    pause
    goto MENU
)

echo [3/4] Creating the scheduled task for the WebClient service...
schtasks /create /tn "Murena WebClient Start" /tr "cmd.exe /c net start WebClient" /sc onlogon /delay %WCFMT% /rl highest /f >nul

echo [4/4] Creating the scheduled task for the drive mapping...
schtasks /create /tn "Murena WebDAV Reconnect" /tr "cmd.exe /c net use %WDRIVE%: /delete & net use %WDRIVE%: \"%UNCPATH%\" /savecred" /sc onlogon /delay %DISKFMT% /rl limited /f >nul

echo.
echo ================================================================
echo  DONE! Both scheduled tasks have been created.
echo ================================================================
echo.
echo IMPORTANT: these tasks are set to trigger "at logon", so they do
echo NOT activate right away - the drive will NOT appear in File
echo Explorer just yet. This is not an error.
echo.
echo Restart the PC. After restarting and logging in (wait at least
echo 1 minute), drive %WDRIVE%: should appear on its own, with no
echo further action needed.
echo ================================================================
pause
goto MENU


:: ================================================================
::  PART A2 - CHANGE PASSWORD (after creating a new app password online)
:: ================================================================
:CHANGEPW
cls
echo ================================================================
echo    CHANGE THE SAVED PASSWORD
echo ================================================================
echo.
echo  IMPORTANT - first make sure you have ALREADY done this:
echo    1. Log in to murena.io
echo    2. Account Settings - Security - App Passwords
echo    3. Revoke the old password, create a NEW one
echo.
echo  This step only saves that new password on this PC.
echo  It does not create new scheduled tasks or change the drive letter.
echo.
set /p PROCEED="Have you already created a new password on Murena? (y/n): "
if /i not "%PROCEED%"=="y" (
    echo.
    echo Please create a new password on murena.io first, then run this option again.
    pause
    goto MENU
)

echo.
set "WSERVER=murena.io"

set "WUSER="
set /p WUSER="Enter your Murena login username: "
if "%WUSER%"=="" (
    echo Username cannot be empty.
    pause
    goto MENU
)

set "WDRIVE="
set /p WDRIVE="Enter the drive letter you already use (e.g. M): "
set "WDRIVE=%WDRIVE:~0,1%"

set "UNCPATH=\\%WSERVER%@SSL\DavWWWRoot\remote.php\dav\files\%WUSER%"

echo.
echo [1/4] Deleting the old saved credential for %WSERVER%...
cmdkey /list > "%TEMP%\ck_list.txt" 2>nul
set "FOUND=0"
for /f "tokens=1,* delims=:" %%A in ('findstr /i "Target:" "%TEMP%\ck_list.txt" ^| findstr /i "%WSERVER%"') do (
    set "TGT=%%B"
    set "TGT=!TGT:~1!"
    echo   - found and deleting: !TGT!
    cmdkey /delete:!TGT! >nul 2>&1
    set "FOUND=1"
)
del "%TEMP%\ck_list.txt" >nul 2>&1
if "!FOUND!"=="0" (
    echo   - WARNING: no saved credential for %WSERVER% was found.
    echo     The old password may have been saved through a different mechanism - continuing anyway.
)

echo [2/4] Restarting the WebClient service, to discard any active
echo        authenticated session held in memory...
net stop WebClient >nul 2>&1
net start WebClient >nul 2>&1

echo [3/4] Disconnecting the current mapping of drive %WDRIVE%:...
net use %WDRIVE%: /delete >nul 2>&1

echo [4/4] Reconnecting - it SHOULD now prompt for username and password...
echo        (if nothing is prompted, a stale entry still exists somewhere)
net use %WDRIVE%: "%UNCPATH%" /savecred
if not "%errorlevel%"=="0" (
    echo.
    echo ERROR: The connection with the new password failed. Check the username and password.
    pause
    goto MENU
)

echo.
echo ================================================================
echo  DONE! The new password is saved. Any existing scheduled tasks
echo  will use it automatically on the next connection.
echo ================================================================
echo.
echo IMPORTANT: even though the connection just succeeded right now,
echo Windows keeps a leftover of the old session/password somewhere
echo in the background, and connecting via File Explorer will report
echo "Access is denied" until the PC is restarted. This is NOT a sign
echo of failure - it's a known Windows quirk when changing WebDAV
echo credentials.
echo.
echo Restart the PC now. After restarting, drive %WDRIVE%: should
echo work completely normally, with the new password.
echo ================================================================
pause
goto MENU


:: ================================================================
::  PART B - REMOVAL (RESET TO ZERO)
:: ================================================================
:REMOVE
cls
echo ================================================================
echo    REMOVE THE SETUP (RESET TO ZERO)
echo ================================================================
echo.

set "WDRIVE="
set /p WDRIVE="Enter the drive letter to disconnect (e.g. M): "
set "WDRIVE=%WDRIVE:~0,1%"

echo.
echo [1/4] Deleting the scheduled tasks...
schtasks /delete /tn "Murena WebClient Start" /f >nul 2>&1
schtasks /delete /tn "Murena WebDAV Reconnect" /f >nul 2>&1

echo [2/4] Disconnecting drive %WDRIVE%:...
net use %WDRIVE%: /delete >nul 2>&1

echo [3/4] Deleting saved credentials...
set "WSERVER=murena.io"

cmdkey /list > "%TEMP%\ck_list.txt" 2>nul
for /f "tokens=1,* delims=:" %%A in ('findstr /i "Target:" "%TEMP%\ck_list.txt" ^| findstr /i "%WSERVER%"') do (
    set "TGT=%%B"
    set "TGT=!TGT:~1!"
    echo   - deleting: !TGT!
    cmdkey /delete:!TGT! >nul 2>&1
)
del "%TEMP%\ck_list.txt" >nul 2>&1

echo.
set "REVERT="
set /p REVERT="Revert the WebClient service back to its default (Manual) startup type? (y/n): "
if /i "%REVERT%"=="y" (
    echo [4/4] Reverting the WebClient service to Manual startup...
    powershell -Command "Set-Service -Name WebClient -StartupType Manual" >nul 2>&1
    net stop WebClient >nul 2>&1
) else (
    echo [4/4] Skipping - the WebClient service is left as-is.
)

echo.
echo ================================================================
echo  DONE! The entire setup has been removed.
echo ================================================================
pause
goto MENU


:: ================================================================
::  PART C - CURRENT STATUS (diagnostics)
:: ================================================================
:STATUS
cls
echo ================================================================
echo    CURRENT STATUS
echo ================================================================
echo.
echo --- WebClient service ---
powershell -Command "Get-Service -Name WebClient | Format-List Name,Status,StartType"
echo --- Connected network drives (net use) ---
net use
echo.
echo --- Scheduled tasks ---
schtasks /query /tn "Murena WebClient Start" 2>nul
echo.
schtasks /query /tn "Murena WebDAV Reconnect" 2>nul
echo.
echo --- Saved credentials containing "murena" ---
cmdkey /list | findstr /i "murena"
echo.
pause
goto MENU


:: ================================================================
::  (end of script)
:: ================================================================

Troubleshooting

If the drive doesn’t come back after a restart, check these in order:

  1. Is Fast Startup enabled? Run powercfg /a in PowerShell. If “Fast Startup” shows as available, powering on after a full shutdown isn’t a genuine cold boot, which can behave differently from a Restart. You can disable it with powercfg /h off if you want consistent behavior.
  2. Increase the gap between the two tasks. 10 seconds was the minimum that worked reliably in my testing (5s / 15s), but slower networks, VPNs, or domain logons may need more (try 10s / 30s).
  3. Check what actually happened, using option 4 in the script, or manually:
   schtasks /query /tn "Murena WebDAV Reconnect" /v /fo LIST

Look at “Last Result” - 0 means success, anything else means it failed on that run.

Thanks for the kind mention of NcDavTray, but NcDavTray doesn’t actually need to be installed at all! There is a dedicated portable mode for this purpose; it runs then from a USB stick or from within a folder in the user directory without installing anything. It does not require elevated privileges, and after deleting the folder where the portable version was extracted—or after unplugging the USB drive—there are absolutely no traces left behind. Plus, portable mode has the advantage of allowing multiple instances of the same tool to run simultaneously.

Fundamentally, just like your solution, NcDavTray is nothing more than a script that utilizes built-in Windows tools. It started out with just a few lines of batch code and evolved into what it is today, with a focus on security and privacy. The only difference is that it is strictly limited to Nextcloud.


ernolf

Thanks for pointing that out. This whole script and setup was put together with help from Claude AI - I first asked it to find a suitable existing solution for me, but it didn’t find yours. Otherwise I’d probably just be using it. It was only after I went to post in the community to help others that I came across your solution myself. I didn’t want to look foolish, so I had the AI do a comparison so it wouldn’t look like I was posting a duplicate. Looks like the comparison didn’t quite work out :smiley:

I’ll correct my post, and hopefully the AI has now analyzed it better, so this solution of mine can still be useful to someone. I set it up for Murena Cloud specifically, but with a few tweaks to the script it should work for any Nextcloud-based WebDAV server with just one line changed. For non-Nextcloud WebDAV servers, the path structure itself would need adjusting too.