I need to copy a file from a Windows 2003 server to a WebDAV folder (on the same server, if it matters). This operation will be performed via a batch script executed via Scheduled Tasks. I've enabled the WebClient service on the server.
So far I've determined that I can do it like this:
net use x: http://host/path
copy c:\path\myfile.txt x:
net use x: /delete
1) Is there a simpler way than creating a temporary mapped drive? Will it work via a batch file when no user is logged in?
2) Is there anything I should know about enabling the WebClient service on my server? Previously it was disabled, which I assume is default.
Best Answer
Free WinSCP (for Windows) supports WebDAV (and WebDAVS). WinSCP supports scripting/command-line operations too.
Sample WinSCP script to upload file over WebDAV:
Save the script to a file (e.g.
script.txt
) and run like:You can also put everything on a single line:
For introduction to scripting with WinSCP, see:
https://winscp.net/eng/docs/guide_automation
WinSCP GUI can generate a script template for you.
(I'm the author of WinSCP)