Batch COPY not working on Windows 8

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

Batch COPY not working on Windows 8

#1 Post by Coder » 04 Dec 2013 13:06

Hi everyone,

I always been using batch scrinting to: COPY, MOVE, DELETE, etc.
Somehow all my attempts with my scripts seem to fail on Windows 8.
Here is what am doing, I want to copy files right from the desktop to:
"C:\WINDOWS\MyFolder" but I get an "ACCESS DENIED" I am aware that
UAC is disable, and also I right-click on my script and run as an administrator,
But still nothing, no matter how I try batch xcopy or copy does not seem to work!
Is there a way arround this?
Thanks in advance

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

Re: Batch COPY not working on Windows 8

#2 Post by foxidrive » 04 Dec 2013 16:52

Folder permissions is what is stopping you. It's a System folder.

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

Re: Batch COPY not working on Windows 8

#3 Post by Coder » 04 Dec 2013 17:05

I know that...
This is my script:

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"

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

Re: Batch COPY not working on Windows 8

#4 Post by foxidrive » 04 Dec 2013 19:06

Coder wrote:This is my script:

Code: Select all

Set MyFolder=%~dp0
Set DestDir=C:\WINDOWS\MyFolder


What is the top command for?

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

Re: Batch COPY not working on Windows 8

#5 Post by Coder » 04 Dec 2013 19:23

Is a variable reference

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

Re: Batch COPY not working on Windows 8

#6 Post by ShadowThief » 04 Dec 2013 19:28

If you're using MyFolder as a variable, it needs to be %MyVariable%

Also, Set MyFolder=%~dp0 will return the full folder name of the folder the script was called from, including the drive letter (that's what the d is for), so calling the script in C:\Users\Coder\Documents\Scripts would have the next command be the equivalent of

Code: Select all

set DestDir=C:\Windows\C:\Users\Coder\Documents\Scripts\

which isn't at all what you want.

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

Re: Batch COPY not working on Windows 8

#7 Post by Coder » 04 Dec 2013 19:38

Shadow, this is what I want to accomplish...
Run my batch script and a folder is create under C:\WINDOWS\MyFolder
Right after that my File.txt will be copied to that directorie
Thats it

But I'm stuck cuz I need a batch script with elevate privileges in order to do this task.

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

Re: Batch COPY not working on Windows 8

#8 Post by ShadowThief » 05 Dec 2013 04:12

Image

I'm not sure what your problem is. I right-clicked and ran the batch file as an administrator like you did and mine works fine.

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

Re: Batch COPY not working on Windows 8

#9 Post by Coder » 05 Dec 2013 12:32

The weird thing on your example is that I don't see the name
of the batch script running. I mean, your example look like when
you run cmd and then type a command and hit enter. and by the way,
here is one thing that I noticed, if you install Windows 8 on Windows 7,
you don't get to see this error that much, it only happens when you try
this on a non-upgrade 8 the other thing I see in your script is that it look
so simple to execute a task like that without getting a single access denied issue.
is that were the case I would't be here looking for this solution, but I had asked this
same question in some many forums and no one seemed to know anything about it.
I just tried this on it and I get an access denied. in conclution what I tried is to change
the extention from .bat to .cmd but still not working. and yeah, what I need is to be able
to copy from one place to this protected sub-directories, sus as Windows, System32, etc.
Thanks Shadow

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

Re: Batch COPY not working on Windows 8

#10 Post by ShadowThief » 05 Dec 2013 15:19

The name of the script isn't supposed to pop up in the title bar of the command prompt (it didn't do this in Windows 7 either), and I definitely right-click-run-as-Administrator'ed the file.

This is a Windows 8.1 Pro virtual machine, completely fresh install.

What happens when you open the command prompt as an Administrator and try to make the folder manually?

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

Re: Batch COPY not working on Windows 8

#11 Post by Coder » 05 Dec 2013 15:40

Shadow, I knew it, yeah, look, if you try this on a laptop or desktop with
Windows 8 that comes with it, for some reasons I get this access denied issue,
But if I take a laptop and I install Windows 8 on it and try, I don't get this issue.
I even post this question on expert-exchange and they tried and then they agree
with me on that subject, is weird but is true, don't know why, and as for your question,
when I run my batch file I always add a PAUSE add an output .log error to check what
went wrong, and yeah, I keep getting ACCES DENIED. last night I finally gived up and
started to write a tool an Visual Basic that can allow me to do this, and so far so good.

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

Re: Batch COPY not working on Windows 8

#12 Post by ShadowThief » 05 Dec 2013 15:49

What version of Windows 8 are you using? Starter? Home? Professional? 8? 8.1? I want to try to match your environment as closely as possible.

Coder wrote: and as for your question, when I run my batch file I always add a PAUSE add an output .log error to check what went wrong, and yeah, I keep getting ACCESS DENIED.

That didn't answer my question at all.

Forget the batch file completely for a second. Open the command prompt as an Administrator. Type in mkdir C:\Windows\MyFolder. Do you still get an ACCESS DENIED error?

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

Re: Batch COPY not working on Windows 8

#13 Post by Coder » 05 Dec 2013 16:11

My bad, here is an screenshot, and yes, I was able to make the dir with no issues,
but I have no problem doing this with a batch file as long as I run the batch as an admin,
But not the copy proccess, that even if I run the batch normal or as an admin, it will not do the trick.
Image

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

Re: Batch COPY not working on Windows 8

#14 Post by Coder » 05 Dec 2013 16:26

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

Image

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

Re: Batch COPY not working on Windows 8

#15 Post by Squashman » 05 Dec 2013 16:28

Is there no Alt+Prtscreen or Snipping Tool in Windows 8 for Screenshots?

Post Reply