AlternateExistance Posted May 20, 2009 Posted May 20, 2009 Hi guys, I am a relatively inexperienced AutoIT user and have a quick question regarding a problem i am having using ShellExecuteWait with Robocopy and a value with spaces in it, for a backup script i have been working on. I am sure it is an easy problem for most of you but i would really appreciate some help. This is the code: ShellExecuteWait("robocopy.exe", " " & $usbdb_source & ":\" & " " & $usbdb_destination & " /E /Z /MIR /XD " & $usbdb_source & ":\" & "RECYCLED" & " " & $usbdb_source & ":\" & "RECYCLER" & " " & $usbdb_source & ":\" & "System Volume Information", $usbdb_dir) The problem is with "System Volume Information" and no matter whether i use 1 or 2 sets of single or double quotes, i still can't seem to get it right for use with Robocopy. Robocopy will not accept it due to the spaces in "System Volume Information". I even tried setting "System Volume Information" as a variable with the following attempts 3 attempts (tried separately): $sysvol = "System Volume Information" $sysvol = '"System Volume Information"' $sysvol = ""System Volume Information"" The final code when using "one" of the above was: ShellExecuteWait("robocopy.exe", " " & $usbdb_source & ":\" & " " & $usbdb_destination & " /E /Z /MIR /XD " & $usbdb_source & ":\" & "RECYCLED" & " " & $usbdb_source & ":\" & "RECYCLER" & " " & $usbdb_source & ":\" & $sysvol, $usbdb_dir) Thanks for your help. Alt
Danny35d Posted May 20, 2009 Posted May 20, 2009 (edited) Open command prompt window and try to use robocopy to copy system volume information folder manually. You going to see Access is denied, even if you have administrator right the only account that can access system information volume folder is the SYSTEM account. Edited May 20, 2009 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
AlternateExistance Posted May 20, 2009 Author Posted May 20, 2009 Hi Danny, I am trying to get RoboCopy to "ignore" and not copy the "System Volume Information" folder (and some other folders) using the "/XD" (exclude directory) option. The folders i am trying to get RoboCopy to ignore are: "RECYCLED" "RECYCLER" "System Volume Information" I have successfully ignored the other folders, just not "System Volume Information" which contains spaces. Thanks, Alt
Danny35d Posted May 20, 2009 Posted May 20, 2009 Give it a try:$usbdb_dir = @ScriptDir $usbdb_source = 'C' $usbdb_destination = 'C:\Temp' $sysvol = 'System Volume Information' ShellExecuteWait('robocopy.exe', $usbdb_source & ':\' & ' ' & $usbdb_destination & ' /E /Z /MIR /R:3 /W:5 /XD ' & '"RECYCLED"' & ' ' & '"RECYCLER"' & ' "' & $sysvol & '"', $usbdb_dir) Note: You want to exclude folders so I remove the drive letter and added double quotes to every folder that you want to exclude. Also added switch /R:3 /W:5 otherwise if robocopy failed copying a file it will try 1,000,000 times and wait 30 seconds before it give up. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
AlternateExistance Posted May 22, 2009 Author Posted May 22, 2009 Hi Danny, That worked great, thanks. Thanks for adding the extra switches in for RoboCopy too. Much appreciated. Is there any way to use a value which contains spaces in the actual command itself or must it be set as a variable beforehand? So far we have set [$sysvol = 'System Volume Information'] but could 'System Volume Information' be used directly in the actual command instead of $sysvol? Under what circumstances should you use single vs double inverted commas? I wasn't able to find that info in the help file but then again i may have missed it though. Thanks again. Alt
Danny35d Posted May 22, 2009 Posted May 22, 2009 (edited) Use a combination of sigle and double quotes. $usbdb_dir = @ScriptDir $usbdb_source = 'C' $usbdb_destination = 'C:\Temp' $sysvol = '"System Volume Information"' ShellExecuteWait('robocopy.exe', $usbdb_source & ':\' & ' ' & $usbdb_destination & ' /E /Z /MIR /R:3 /W:5 /XD ' & '"RECYCLED"' & ' ' & '"RECYCLER"' & ' ' & $sysvol, $usbdb_dir)oÝ÷ ØêÚºÚ"µÍÌÍÝØÙHØÜÌÍÝØÜÛÝÙHH ÌÎNÐÉÌÎNÂÌÍÝØÙÝ[][ÛH ÌÎNÐÎÌLÕ[ ÌÎNÂÚ[^XÝ]UØZ] ÌÎNÜØØÛÜK^IÌÎNË ÌÍÝØÜÛÝÙH [È ÌÎNÎÌLÉÌÎNÈ [È ÌÎNÈ ÌÎNÈ [È ÌÍÝØÙÝ[][Û [È ÌÎNÈÑHÖÓRTÔÈÕÎHÖ ÌÎNÈ [È ÌÎNÉ][ÝÔPÖPÓQ ][ÝÉÌÎNÈ [È ÌÎNÈ ][ÝÔPÖPÓT][ÝÉÌÎNÈ [È ÌÎNÈ ][ÝÔÞÝ[HÛ[YH[ÜX][Û][ÝÉÌÎNË ÌÍÝØÙ Edited May 22, 2009 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
AlternateExistance Posted May 28, 2009 Author Posted May 28, 2009 I changed the code to allow for the use of source and destination directories with spaces in their names, but i can't quite get it to work properly for some reason. $usbdb_dir = 'C:\Program Files\Robocopy\robocopy.exe' $usbdb_source = 'T:\' $usbdb_destination = 'Z:\DAILY BACKUPS\E DRIVE BACKUPS\' ShellExecuteWait($usbdb_dir, $usbdb_source & ' "' & $usbdb_destination & '"' & ' /E /Z /MIR /R:3 /W:5 /XD ' & '"' & $usbdb_source & 'Recycled\' & '" "' & $usbdb_source & 'Recycler\' & '" "' & $usbdb_source & 'System Volume Information\' & '"') The reason i added $usbdb_source to the ignored directories was that i found that RoboCopy was ignoring all sub folders of $usbdb_source called "RECYCLED", "RECYCLER" and "System Volume Information". If $usbdb_source was a directory rather than the root of the drive, ignoring sub folders named "Recycled" etc may be an issue under certain circumstances. I am aware that if the $usbdb_source is a sub directory of a drive and contains folders called "RECYCLED", "RECYCLER" or "System Volume Information" that those folders will not be copied. After the first issue is resolved, I will need to sit down and work out how to obtain the drive letter of $usbdb_source and set that as a separate variable to be used with $usbdb_source & 'Recycler\' In batch i would have used: ::GET AND SET DRIVE LETTER CD\ set drive=%cd% Thanks again for the help, Alt
AlternateExistance Posted May 28, 2009 Author Posted May 28, 2009 I also meant to say that when i ran the RoboCopy code using MsgBox rather than ShellExecuteWait, it "looks" correct in the popup from what i can see: $usbdb_dir = 'C:\Program Files\Robocopy\robocopy.exe' $usbdb_source = 'T:\' $usbdb_destination = 'Z:\DAILY BACKUPS\E DRIVE BACKUPS\' MsgBox(0, $usbdb_dir, '"' & $usbdb_source & '" "' & $usbdb_destination & '"' & ' /E /Z /MIR /R:3 /W:5 /XD ' & '"' & $usbdb_source & 'Recycled\' & '" "' & $usbdb_source & 'Recycler\' & '" "' & $usbdb_source & 'System Volume Information\' & '"', 60) Maybe i missed something though. Thanks, Alt
AlternateExistance Posted June 3, 2009 Author Posted June 3, 2009 The problem turned out to be a RoboCopy issue where RoboCopy would fail if a trailing backslash was used. This code works well (for anyone who is interested): $usbdb_dir = 'C:\Program Files\Robocopy\robocopy.exe' $usbdb_source = 'T:' $usbdb_destination = 'Z:\DAILY BACKUPS\E DRIVE BACKUPS' ShellExecuteWait($usbdb_dir, '"' & $usbdb_source & '" "' & $usbdb_destination & '"' & ' /E /Z /MIR /R:3 /W:5 /XD ' & '"' & $usbdb_source & '\Recycled' & '" "' & $usbdb_source & '\Recycler' & '" "' & $usbdb_source & '\System Volume Information' & '"') Alt
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now