Friday, 27 March 2020

Batch file for establishing a WebDAV connection and bind it to a drive letter (non-persistent).

:REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:REM
:REM Batch file for establishing a WebDAV connection and bind it to a drive
:REM letter (non-persistent).
:REM
:REM Please adopt WEBDAV_HOST and WEBDAV_USER to your needs as well as the
:REM default password. You also might want to adopt the default drive the
:REM WebDAV connection should be bound to.
:REM
:REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:REM ~~~~~~~~~~
:REM PARAMETERS
:REM ~~~~~~~~~~
set WEBDAV_HOST=http://your.webdav.host/somedrive
set WEBDAV_USER=YourUsername
:REM Use "*" to let "net use" ask you for the password. You might
:REM change this to the real password but mind that this is a security risk.
set WEBDAV_PASSWORD=*
set DRIVE=X:
if exist %DRIVE% (
echo Drive %DRIVE% already in use. Choosing the next free one...
set DRIVE=*
)
:REM ~~~~~~~~~~~~~~~~~~~~
:REM Establish Connection
:REM ~~~~~~~~~~~~~~~~~~~~
echo Establishing connection to "%WEBDAV_HOST%" for "%WEBDAV_USER%"...
echo.
net use "%DRIVE%" "%WEBDAV_HOST%" /User:"%WEBDAV_USER%" "%WEBDAV_PASSWORD%" /persistent:no
if not errorlevel 1 (
echo.
net use
)
:END
@echo off

No comments:

Post a Comment

Note: only a member of this blog may post a comment.