Jump to content

Recommended Posts

Posted

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 ?

Posted

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 ?

Posted

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 :)

Posted

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 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

Posted

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.

 

@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:\[b]SomethingUnique.txt[/b] SET FlashDrive=%%i:\

RoboCopy %FlashDrive% c:\progra~1\luk\lukinfo /s

Posted (edited)

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

Edited by box_l
Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...