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
robocopy d:\/e c:\progra~1\luk\lukinfo
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 ?
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
Thanks for the support.
I tried ...
robocopy d:\ /e "c:\progra~1\luk\lukinfo"
robocopy d:\ "c:\progra~1\luk\lukinfo /e"
robocopy d:\ "c:\program files\luk\lukinfo" /e
robocopy d:\ "c:\program files\luk\lukinfo /e"
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 ?
robcopy needs /s to copy subdirectories (/e copies empty sub-directories)
robocopy D:\ c:\progra~1\luk\lukinfo /s
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 :)
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.
Set Service = Locator.ConnectServer(".")
Set items=service.execquery("Select * from Win32_LogicalDisk where drivetype=2") 'dt 2 is removable
For Each item In items
if ucase(item.volumename)="MYUSB" then sLetter=item.name
if sLetter="N/A" then
wscript.echo "Can't find memory stick; ending"
sCmd="robocopy c:\" & sSrc & " " & sLetter & "\" & sDest & " /fft /mir /w:1 /r:1" 'fat file time
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)? :confused:
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.
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
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)
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