11

Something like

cp \\target_machine local_file.txt c:\dest_file.txt
Kenster
  • 7,483
  • 2
  • 32
  • 44
Behrang
  • 2,032
  • 5
  • 19
  • 26

2 Answers2

13

Assuming you have appropriate permissions, you can do it like this:

copy local_file.txt \\target_machine\c$\dest_file.txt

Use "c$" to reference C drive on the remote machine.

Ash
  • 2,984
  • 4
  • 27
  • 30
  • How do you include a username and password to authenticate if you don't have appropriate permissions? – ArtOfWarfare Mar 18 '18 at 14:33
  • 1
    Searching around suggests `net use` to provide the authentication to the share before copying (eg: https://stackoverflow.com/questions/3854026). Not sure if that works with the c$ notation above though, you'd have to try it and see. – Ash Mar 19 '18 at 09:11
1

It's like this:

copy c:\local_path\local_file.txt \\target_machine\destination_path\destination_file.txt

If you have \\target_machine\destination_path\ mapped to a network drive, say, Z: then the command becomes

copy c:\local_path\local_file.txt Z:\destination_file.txt

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
  • when I try the first option (without the c$ stuff) I get "The system cannot find the path specified" or "The network name cannot be found", depending on one or two backslashes before machine name. – Ash Oct 08 '10 at 05:15
  • Hmm, there was an error in Markdownformatting which showed only single backslash instead of 2. If you're getting `The network name cannot be found` then it's a network problem, either you don't have permissions or the firewall is blocking your requests – Sathyajith Bhat Oct 08 '10 at 12:23
  • I tried both one and two backslashes, and got the different error messages depending on which I used. "Network name cannot be found" was with two backslashes. Interesting. That works with your network setup? It didn't work with either our server or other clients... – Ash Oct 08 '10 at 13:45
  • @Ash single backslash indicates you are accessing the current drive, hence you got the `system cannot find path specified error`. Double backslash is used for accessing network shares with UNC naming scheme. Yes, this works on my network, I have couple of scripts where I make use of this ( scripts are to export data, compress them and move them to NAS). I suspect permissions problems. Are the machines you want to copy on different domains/workgroups ? – Sathyajith Bhat Oct 08 '10 at 13:59
  • On Windows machines/networks, a share such as `c$` must be used. – Timtech Mar 27 '15 at 00:24