Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know that the robocopy command will only work with existing drives, not remote servers, so if I'd like to use the robocopy command to run periodic file backups from a remote server, I have to map that to a network drive.

My script so far is something like this:

rem # Map the drive
net use R: \\server\path-to-file /USER:username
rem # Now use robocopy
robocopy.exe R:\ C:\local\backup\destination
rem # Disconnect the mapped drive
net use R: /delete

In the first line where I map the remote server to a local network drive, is there a way for me to specify a login with a private key location, rather than a password? That's the only way I can connect to my remote server.

Any ideas would be much appreciated! :-)

share|improve this question
What program do you normally use to connect to the server? I'm pretty sure SMB does not support public-key auth at all. –  grawity Nov 30 '12 at 19:16
Well, I typically use ssh or WinSCP to login to the remote server (which is a web server) and both of those applications allow me to login using my locally stored private key. Public key is on the server. I have never done this through a Windows batch file, which I think is what I need to setup a file backup script that runs nightly. Thus my question above. Is that what you meant when you asked how I normally connect to the server? –  Boriana Nov 30 '12 at 19:25
winscp.net/eng/docs/… ? –  Luiz Angelo Nov 30 '12 at 19:40
@Boriana: Yes, that's what I meant. –  grawity Nov 30 '12 at 20:13
add comment

1 Answer

up vote 0 down vote accepted

You mentioned that you use SFTP via WinSCP to connect to the server, and unfortunately Windows does not support that natively (you can only use SMB or WebDAV with \\server or with net use).

This also means you won't be able to use robocopy with it, either. (Unless you install something like Dokan SSHFS, but I'm afraid that project is a bit out-of-date.)

However, if all you need to do is download a complete directory, WinSCP's automation (scripting) can do that easily, using the synchronize function. Write a script similar to:

option batch abort
option confirm off
open mysession
synchronize local -mirror -delete C:\local\backup\destination /path/to/source
share|improve this answer
Thank you!!! I'll use WinSCP scripting. My tests so far are working well! –  Boriana Nov 30 '12 at 22:12
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.