Tips and Tricks - robocopy.exe and subinacl.exe

Ever wanted to copy a large file across the network and cope with resuming where you left off when the remote desktop session kills your copy?

Well now you can!

Robocopy is an excellent piece of kit, distributed as part of the windows resource kits for Windows 2k, XP Pro and 2003 Server.

Subinacl allows you to take ownership of your files in bulk!

Here is a neat trick from Solo Enterprises… I’ve stolen it (it copies the contents of a hard drive) and made some amendments below:

Requirements:

  • Windows 2000,XP Pro, 2003 Server
  • robocopy.exe- in the windows resource kits or download here (save as)
  • subinalc.exe- in the windows resource kits or download here (save as)

Conventions:

  • For this example we will assume that
  • robocopy.exe and subinacl.exe are in your local PATH
  • The C: drive is your main hard drive
  • I generally pull the harddrive out of the client computer and transfer the data from a workstion to our backup server using a removable drive tray.
  • the SOURCE is the F: Drive and is an NTFS file system. (if not NTFS, just remove the first line in the batch file below)
  • The SOURCE is NOT the partition that is running Windows currently.
  • the destination is a mapped network folder T:\test

Install both of these and then create a new text file called robocopy.cmd on your desktop.

Line 1 will use subinacl to take ownership of all the file on the SOURCE and give Everyone Full Control of the files and folders. I had to do this because some security settings will cause a failure copying files. Especially ones in application data and local settings.

start /wait subinacl.exe /errorlog="C:\errorlog.txt" /nostatistic
/subdirectories F: /Owner=user@machine.local /grant=Everyone=F
/objectexclude=*.swp
/objectexclude=*.dmp
/objectexclude=*.tmp
/objectexclude=pagefile.sys
/objectexclude=hiberfil.sys

  • start /wait subinacl .exe //this starts the script and waits for it to complete before moving to the next line in the batch file
  • /errorlog="C:\errorlog.txt" //this saves an error log to the path specified
  • /nostatistic //this suppresses displaying the progress
  • /subdirectories //Makes it do all files and subdirectories in the path specified
  • F: //Path to hard drive
  • /Owner=user@machine.local //Who takes ownership of the files
  • /grant=Everyone=F //Grant Everyone Full Permissions
  • /objectexclude=*.tmp // no need wasting time on a file we aren’t going to copy.

Line 2 Will robocopy the entire contents of the harddrive expect: *.swp *.dmp *.tmp pagefile.sys hiberfil.sys "_RESTORE" "MSOCache" "Recycled" "RECYCLER" "Temporary Internet Files" "System Volume Information" "WUTemp"

I don’t copy those files because I have never run into a time when I needed anything in any the folders and it just wastes time to copy them.

start /wait robocopy.exe F:\ T:\test /E /ZB /COPY:DAT /IA:RASHNTCEO /X /V /FP /XF *.swp *.dmp *.tmp pagefile.sys hiberfil.sys /XD  "_RESTORE" "MSOCache" "Recycled" "RECYCLER" "Temporary Internet Files" "System Volume Information" "WUTemp" /R:1 /W:0 /LOG:"C:\robolog.txt" /TEE
  • start /wait robocopy .exe //this starts the script and waits for it to complete before moving to the next line in the batch file
  • F:\ //Source
  • T:\test //Destination

So now just double click robocopy.cmd on your desktop and away it goes…

Enjoy

SpittingCAML




You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “Tips and Tricks - robocopy.exe and subinacl.exe”

  1. Liza Says:

    Hey, cool tips. I’ll buy a glass of beer to that man from that forum who told me to go to your blog :)

  2. Yan Herndon Says:

    Hey its not theft, you gave me a link. I actually googled it because I couldnt remeber where I posted that script and had a need for it again. Glad I left the old site up.
    Now lets see if it works on Win7.

  3. SpittingCAML Says:

    Hey no worries, I didn’t realise soloenterpises ceased to exist :-)

    Martin

Leave a Reply