Batch COPY not working on Windows 8

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: Batch COPY not working on Windows 8

#16 Post by Squashman » 05 Dec 2013 16:32

That error has nothing to do with permissions or Access Denied.

I personally think you are not showing us the real batch file or all of the batch file because the script code you showed us really doesn't make a whole lot of sense.

Code: Select all

Set MyFolder=%~dp0
Set DestDir=C:\WINDOWS\MyFolder
Mkdir "%DestDir%" 2>NUL
COPY "C:\users\%username%\desktop\File.txt" "C:\WINDOWS\MyFolder\File.txt"

1) Why the SET statement for the variable MyFolder if you are not going to use that variable in the rest of the script.

2) Why set a variable for DestDir and only use it to Make the Directory but not use it for the Copy command?

Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#17 Post by Coder » 05 Dec 2013 16:34

Windows 8 include the Snipping Tool the same from Windows Vista and Windows 7
Then is not, you can also use the [ Print ] button and then just paste it on Paint and save it.
Why ?

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: Batch COPY not working on Windows 8

#18 Post by Squashman » 05 Dec 2013 16:35

Coder wrote:Windows 8 include the Snipping Tool the same from Windows Vista and Windows 7
Then is not, you can also use the [ Print ] button and then just paste it on Paint and save it.
Why ?

Alt+PrintScreen captures the active window. No need to capture the whole desktop. Snipping Tool can do the same thing.

ShadowThief
Expert
Posts: 986
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch COPY not working on Windows 8

#19 Post by ShadowThief » 05 Dec 2013 16:39

Coder wrote:This is the error I get if I try to copy files:

Image

This error occurs when (as you can probably guess) at least one of the two folders in the copy command doesn't exist. Based on your screenshot, I'm going to say that it's C:\users\%username%\desktop\File.txt, since you've already shown that C:\Windows\MyFolder exists.

Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#20 Post by Coder » 05 Dec 2013 16:40

Squashman, I have nothing to hide from my script, all I need is to be able to copy from
one location to another, but in this case is to these system directories: Windows & System32
and as for the "Alt+Prtscreen" I know that since Windows 98, then reason I'm posting the whole
screen is because I wanted to share the same Shadow did which I don't think there is a problem right?

Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#21 Post by Coder » 05 Dec 2013 16:45

No Shadow, the files are there, the files were behind the cmd window,
the error point to a path "The system cannot find the path specified."
but the path is there, this is due to a elevate permision needed

ShadowThief
Expert
Posts: 986
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch COPY not working on Windows 8

#22 Post by ShadowThief » 05 Dec 2013 16:55

If it were a permissions issue, you would get a permissions-related error. This is an error related to the file and/or path specified not existing. There is literally nothing else the error could refer to.

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: Batch COPY not working on Windows 8

#23 Post by Squashman » 05 Dec 2013 16:56

Lets see the output from this.

Code: Select all

@echo off
type %~dpnx0
Set MyFolder=%~dp0
Set DestDir=C:\WINDOWS\MyFolder
Mkdir "%DestDir%" 2>NUL
echo %cd%
IF EXIST "C:\users\%username%\desktop\File.txt" echo Input File exists
IF EXIST "C:\Windows\MyFolder\" echo Folder: C:\Windows\MyFolder\ exists
COPY "C:\users\%username%\desktop\File.txt" "C:\WINDOWS\MyFolder\File.txt"
pause


Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#24 Post by Coder » 05 Dec 2013 17:42

The system cannot find the file specified.
Error occurred while processing: C:\Users\Documents\Desktop\Copy.
The system cannot find the file specified.
Error occurred while processing: File.CMD.
C:\Users\Documents\Desktop
Input File exists
Folder: C:\Windows\MyFolder\ exists
Access is denied.
0 file(s) copied.

Press any key to continue . . .


Image

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: Batch COPY not working on Windows 8

#25 Post by Squashman » 05 Dec 2013 17:57

You didn't run it as Administrator.

Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#26 Post by Coder » 05 Dec 2013 18:35

You right Squashman, I just did, and guess what, the file was copied with no issues!
But that was a 0 bytes file, and was just one, but no excuses, the file was copied!
I just tried from a pen-drive but did not worked, but thats because I included the
path in this order: "COPY "\MyPendrive\File.txt" "C:\Windows\MyFolder\File.txt"
But I'll play with it and see how to get arround that.
Thanks very much Squashman

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Batch COPY not working on Windows 8

#27 Post by foxidrive » 05 Dec 2013 19:56

This works when right clicking and run as admin, but not when just executing it - even if UAC is turned off.

It will not create the folder because of insufficient permissions.

Code: Select all

@echo off
Set "DestDir=C:\WINDOWS\MyFolder"
Mkdir "%DestDir%"
echo 1
if not exist "%destdir%\" pause
echo aaa>"%userprofile%\desktop\File.txt"
COPY "%userprofile%\desktop\File.txt" "%destdir%\"
echo 2
if not exist "%destdir%\file.txt" pause
echo 3
pause
if exist "%destdir%\" rd "C:\WINDOWS\MyFolder" /s /q
del "%userprofile%\desktop\File.txt"
pause

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Batch COPY not working on Windows 8

#28 Post by Dos_Probie » 06 Dec 2013 20:27

add this then right click and run as admin..DP

Code: Select all

COPY "%userprofile%\desktop\File.txt" "C:\WINDOWS\MyFolder\File.txt"

Coder
Posts: 14
Joined: 04 Dec 2013 12:50

Re: Batch COPY not working on Windows 8

#29 Post by Coder » 08 Dec 2013 01:18

Hey guys, how about from portable drive to these protected directories?
I mean, something like this: "\MyFolder\File.txt" "C:\Windows\MyFolder\File.txt"
This works perfect for me on Windows XP, Vista and Windows 7, but not on Windows 8.
I get the Access Denied issue, any idea? Thanks guys,

Post Reply