Copying from one Windows share to another

Cruelty

Well-Known Member
Joined
Jan 19, 2011
Messages
339
Reaction score
33
Location
JHB
Something I've always wondered, but never bothered enough to look into ...

Say I have 2 Windows machines on a network. Let's be very creative and call them WIN1 and WIN2. And let's use the $ admin shares.

On WIN1, I have drive S: mapped to \\WIN2\C$. I also have drive T: mapped to \\WIN2\D$
Using Windows Explorer on WIN1, I copy a file from S: to T:. What happens:

1) The file is read from WIN2 over the network to WIN1, and written back over the network to WIN2.
2) Some magic kicks in and WIN2 writes the file directly to the destination UNC path (i.e. it does go through WIN2's NIC) and Windows somehow simulates permissions.
3) Some AI magic kicks in and WIN2 writes the file directly to its D: drive (i.e. it bypasses its own NIC.)
4) some combination of the above based on what Windows decides is possible and most efficient

1) is massively inefficient, but probably most likely (consider permissions, if S: and T: are on different machines / networks, etc)
2) would be way more efficient, but not super efficient
3) would be pie-in-the-sky amazing.
 
@Cruelty
You want to put files in one path and have the automatically copied to another while retaining permissions?

If so then Robocopy (a free Microsoft application not many people know about) can do this. I can help you with the variables.

/secCopies files with security (equivalent to /copy: DATS).
/mon:<N>Monitors the source, and runs again when more than N changes are detected.
/mot:<M>Monitors source, and runs again in M minutes if changes are detected.

Also Robocopy only copies files that have changed. Doesn't rewrite files that haven't changed.
 
Last edited:
Robocopy is indeed the tool. Connect with remote desktop to one machine, and run it from there to avoid going through a third machine. Make sure the folders have AD permissions and not local permissions if you want to preserve security. Robocopy is more efficient than Explorer copy.
 
This is one of the better explanations https://adamtheautomator.com/robocopy-the-ultimate/

Just read through the article and you will find out how much you can do with Robocopy.
Understanding What Robocopy can Do
If you've used copy or PowerShell's Copy-Item cmdlets, you've probably specified a source and destination and went on about your day. There's not a whole lot of options you can configure there. These commands have a default behavior.

But robocopy, on the other hand, understands a lot more and gives you the flexibility to tweak the behavior as much as you want.

It's important to know robocopy isn't just aware of the concept of a file or directory. There's a lot more to a filesystem than that and robocopy supports just about everything.

A file sitting on a filesystem isn't just a dumb object with a single purpose. There are many different attributes and things that go with the concept of a file. For example, a file has attributes such as:

  • a timestamp (written, modified and accessed)
  • NTFS ACL
  • an owner
  • NTFS auditing information
  • hidden flag
  • archived flag
When you copy or move a file, you have the option to bring all of that stuff along with it, if you want.

Understand that when you run robocopy, you're not just copying a file, you're also potentially copying all of the other information with it. It's important to realize that and to account for it in the options you provide robocopy.
 
+1 for Robocopy, very robust and useful tool.
 
Example of one of the codes I run from a batch file that copies backup files to a memory stick.
Code:
Title Copy Alpro Backups
robocopy "c:\Alpro\Backup" "G:\Backups\Month End Backups\2020\%date:~3,2%\Alpro backups" auto_2020-%date:~3,2%-*.cab /log+:"G:\Backups\Logs\Log.txt" /v
robocopy "c:\Alpro\Line Checks" "G:\Backups\Line Checks" /mir /log+:"G:\Backups\Logs\Log.txt" /v
 
Top
Sign up to the MyBroadband newsletter
X