+ Post New Thread
Results 1 to 9 of 9
Windows Vista Thread, Using Robocopy in Technical; Hi I am trying to write an install file to overight some files on the hard drive using either a ...
  1. #1

    Join Date
    Oct 2009
    Location
    Birmingham
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Using Robocopy

    Hi
    I am trying to write an install file to overight some files on the hard drive using either a CD or Memeory stick into multiple directories.
    I managed it fine on XP machines using the following

    xcopy *.*/e/y c:\"program files"\luk\lukinfo

    This however does not work with Vista.
    I figured out that the "program files" doesnt work so tried the short dos version

    I have tried....

    robocopy d:\ c:\progra~1\luk\lukinfo
    and
    robocopy d:\/e c:\progra~1\luk\lukinfo
    and
    robocopy d:\ c:\progra~1\luk\lukinfo/e
    and lots of other variations

    Whilst it copies the files from the root directory of my stick (D it does not copy the files in the subdirectories regardless of where I put the /e switch ???

    I will put the /y switch back in when I am happy it works OK.

    I think I will also have a problem if winders allocates a different drive letter to the memory stick or CD.

    Can anyone help ?

  2. #2
    kearton's Avatar
    Join Date
    May 2007
    Location
    Yorkshire, via NZ ;)
    Posts
    887
    Thank Post
    175
    Thanked 113 Times in 91 Posts
    Rep Power
    48
    Try putting the quotes around the whole path, not just the Program Files bit. e.g "c:\program files\luk\lukinfo"
    And put a space before the /e

  3. #3

    Join Date
    Oct 2009
    Location
    Birmingham
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Using Robocopy

    Thanks for the support.

    I tried ...

    robocopy d:\ /e "c:\progra~1\luk\lukinfo"
    and
    robocopy d:\ "c:\progra~1\luk\lukinfo /e"
    and
    robocopy d:\ "c:\program files\luk\lukinfo" /e
    and
    robocopy d:\ "c:\program files\luk\lukinfo /e"
    and
    Xcopy *.*/e "c:\program files\luk\lukinfo"

    and all of them stop at the install.bat file which I am using to overight the files saying access denied ?

    I am in administration account.
    Tried doing in a cmd window with the same result ?

    any more ideas ?

  4. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    robcopy needs /s to copy subdirectories (/e copies empty sub-directories)

  5. #5

    Join Date
    Oct 2009
    Location
    Birmingham
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Using robocopy

    Brilliant !!!

    robocopy D:\ c:\progra~1\luk\lukinfo /s

    works great..

    However ... how can i get round the issue of winders allocating the memory stick a different drive letter on another machine i.e. if it calls if F: robocop D:\ wont work ???

    Thanks alot

  6. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    This vbscript might help. Basically, it looks at each removable device and checks the label. When it finds "MYUSB" it knows the drive letter and runs robocopy from specific folders on the C: drive to the backup device - in the example it backs up c:\work\photos to a folder called pictures on the device and c:\music to a folder called music on the device.

    The /mir means mirror - it deletes from the device if it's been deleted from the source - if you don't want that then change it to /s /e
    The /w:1 and /r:1 mean wait 1 second if there's a problem and retry once; by default robocopy wil retry from now until the Christmas after next - if there's a temporary glitch, 1 retry is enough!
    Finally, /fft says use FAT file times - NTFS is more precise than FAT in file times and I had problems with files copying because somehow robocopy thought they were different even though they were the same; you may not need it.

    Code:
    set oShell=createobject("wscript.shell")
    set oFSO=createobject("scripting.filesystemobject")
    Set Locator=CreateObject("WbemScripting.SWbemLocator")
    Set Service = Locator.ConnectServer(".")
    Set items=service.execquery("Select * from Win32_LogicalDisk where drivetype=2") 'dt 2 is removable
    sLetter="N/A"
    For Each item In items
      if ucase(item.volumename)="MYUSB" then sLetter=item.name
    Next
    if sLetter="N/A" then
      wscript.echo "Can't find memory stick; ending"
      wscript.quit
    end if
    BackupFolder "work\photos","pictures"
    BackupFolder "music","music"
    
    
    sub BackupFolder(sSrc,sDest)
      sCmd="robocopy c:\" & sSrc  & " " & sLetter & "\" & sDest & " /fft /mir /w:1 /r:1" 'fat file time
      oShell.run sCmd
    end sub

  7. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,390
    Thank Post
    241
    Thanked 2,817 Times in 2,078 Posts
    Rep Power
    813
    Don't you need elevated privileges in Windows Vista and 7 to write files to %ProgramFiles% or %SystemRoot%? Isn't that why MGTechman is getting Access Denied errors (even as Administrator)?

    Another way to search for the drive letter of the USB flash drive would be to do something like the following. As long as you have a file that is unique on the flash drive, the batch file will be able to find the drive letter of it. The file can be anything you want - even an empty text file.

    Code:
    @echo off
    SET FlashDrive=NULL
    
    FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\SomethingUnique.txt SET FlashDrive=%%i:\
    
    RoboCopy %FlashDrive% c:\progra~1\luk\lukinfo /s

  8. #8
    box_l's Avatar
    Join Date
    May 2007
    Location
    Herefordshire
    Posts
    436
    Thank Post
    75
    Thanked 94 Times in 78 Posts
    Rep Power
    63
    why search for the drive letter?

    it looks like you want to do this on multiple machines, so why not have a batch file with that command in it, and the robocopy file sat on the stick right next to all the files to be copied.

    your command would then be:

    %~dp0/robocopy.exe %~dp0/lukinfo c:\progra~1\luk\lukinfo /s

    %~dp0 is windows cmd for present working directory (PWD)

    Regards

    BoX
    Last edited by box_l; 6th November 2009 at 02:02 PM.

  9. #9

    Join Date
    Oct 2009
    Location
    Birmingham
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Robocopy

    Box
    Thats exactly what I am trying to do and the %~dp0 looks like the missing link !
    Didnt find that on any "how to use Robocopy" sites.

    Will try it the weekend
    Many Thanks

SHARE:
+ Post New Thread

Similar Threads

  1. Robocopy some help...
    By Nemernic in forum Scripts
    Replies: 6
    Last Post: 28th July 2009, 11:23 AM
  2. Robocopy where is it and how do I use it?
    By speckytecky in forum Windows
    Replies: 10
    Last Post: 29th July 2008, 09:29 AM
  3. Robocopy Help
    By Gatt in forum Windows
    Replies: 2
    Last Post: 11th July 2008, 11:06 AM
  4. Robocopy Help
    By soze in forum How do you do....it?
    Replies: 15
    Last Post: 2nd June 2008, 02:42 PM
  5. Robocopy
    By acrobson in forum How do you do....it?
    Replies: 16
    Last Post: 22nd December 2007, 01:41 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •