Run robocopy bat to copy the entire disk to another disk

I am trying to run a simple backup (mirror) of one whole disk (d :) to another disk (k :). I created a .bat file ('backup.bat') that defines the source (d :) and destination (k :) and placed this batch file in a folder on d (d: \ temp). When I double-click on a batch file, it defines the source as d: \ temp, not the one I defined as in the batch file; d :.

Here is the text in the .bat file:

@echo off echo To begin backing up data: pause robocopy "D:" "K:" /L /v echo. pause exit 

And this is what appears when I double click on backup.bat

enter image description here

As you can see, the source is defined as d: \ temp. Here is the batch file, but in the batch file I defined it as D :. For some reason, the assignment is determined correctly.

Any ideas?

-al

EDIT: if I add '/' to the source and destination location, see the code below, I see even weirder behavior (see screenshot). The source is now both the designated source and destination, without destination.

 @echo off echo To begin backing up data: pause robocopy "D:\" "K:\" /L /v echo. pause exit 

enter image description here

And if I remove the "" from the source and destination ... IT WORKS!

 @echo off echo To begin backing up data: pause robocopy D:\ K:\ /L /v echo. pause exit 

enter image description here

+6
source share
2 answers

with "D:" you are not specifying the root directory of drive D ( D:\ ), but instead of the current directory D ( D:\temp in your example).

To solve this problem, just add \ to the original specification (and for now, to the dest specification)

 robocopy d:\ k:\ /L /v 
+5
source

Use the /E option. Also check other necessary / useful options, such as /copyall /ZB or /DCOPY:DAT via /? .

+2
source

All Articles