3

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.

2
  • Nothing simpler without using 3rd party software. User doesn't have to be logged in; but the batch file will run as a user, that user will get the mappings...
    – Chris S
    Aug 4, 2011 at 15:02
  • 1
    In your question you state that the WebDAV folder is on the same server, but in response to my answer, you say that it is a different server. Please pick one and clarify.
    – gWaldo
    Sep 14, 2011 at 12:13

4 Answers 4

3

Free WinSCP (for Windows) supports WebDAV (and WebDAVS). WinSCP supports scripting/command-line operations too.

Sample WinSCP script to upload file over WebDAV:

open http://[email protected]/
put file.txt /path/
close

Save the script to a file (e.g. script.txt) and run like:

winscp.com /script=script.txt

You can also put everything on a single line:

winscp.com /command "open http://[email protected]/" "put file.txt /path/" "close"

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)

1

Why, oh why, (if it's on the same server) don't you copy from local folder to local folder?

copy c:\path\myfile.txt c:\path\to\www-root\subdir\destination\

You may need to restart IIS/Apache (or whatever) after the file is copied, but most likely not.

4
  • It's not on the same server, of course.
    – Boden
    Sep 6, 2011 at 3:15
  • Don't you specify that it is in the same server in the original post?
    – gWaldo
    Sep 6, 2011 at 15:03
  • 1
    If they are different servers in the same LAN, you can just do a normal net use x: \\server\share and then copy.
    – gWaldo
    Sep 6, 2011 at 15:06
  • 1
    @gWaldo, you're assuming the WebDav is just serving a file directory. I know SharePoint in particular allows you to mount Sites as WebDav folders, but it's all stored in the DB. This might be something similar.
    – Chris S
    May 28, 2012 at 14:42
1

DavCopy is a command line tool to push files to WebDAV. It supports command line authentication for batch jobs, so it can run when you're not logged in.

The webclient service isn't needed to run the tool.

It uses simple syntax, too. similar to robocopy.syntax!

0

You might try using pushd and popd, which help automate the mounting of the drive some. You also might try using PowerShell, if possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .