4
copy C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe 
     C:\Users

returns

The system cannot find the file specified. when the executable exists in that directory!

Legends
  • 21,202
  • 16
  • 97
  • 123
MinCarve
  • 75
  • 1
  • 3
  • 15

2 Answers2

7

The path of your file has a space in its name, which means you have to surround the path which contains spaces with quotation marks.

sininen
  • 503
  • 1
  • 6
  • 20
1
copy C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe C:\Users

has FOUR parameters. It tries to copy
C:\Users\MinCarve\documents\visual (which does (probably) not exist) to the location
studio (which (probably) doesn't exist too, and two more parameters:
2017\Projects\PROGRAM\Debug\PROGRAM.exe
C:\Users

Copy stops with the first error found, in this case, C:\Users\MinCarve\documents\visual does not exist.

Solution: quote parameters that contain one or more spaces. Best practice: do it anyway: copy "source" "destination".

copy "C:\Users\MinCarve\documents\visual studio 2017\Projects\PROGRAM\Debug\PROGRAM.exe" "C:\Users\"
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • @Kirsten: is that the explanation you are looking for, or do you need anything more? – Stephan Feb 24 '23 at 14:12
  • Thanks @Stephan. I think my problem may be something to do with the vm being on a Linux box. I may need to ask a separate question. As a work around I just got rid of the spaces. – Kirsten Feb 24 '23 at 18:35
  • 1
    Shouldn't make a difference whether Win runs on a physical or virtual machine. – Stephan Feb 24 '23 at 18:47
  • I think it might be a permissions thing. I was able to run a similar command as administrator. I was copying to a subfolder of C:\Program Files (x86) – Kirsten Feb 25 '23 at 00:41
  • 1
    yes, that folder tree needs Admin rights to write to. – Stephan Feb 25 '23 at 08:53