Search code examples
permissionsbatch-fileaccess-deniedxcopy

xcopy "Access denied" with /y /o /s /c /h


I'm currently refining and updating my offline virus database updater for Malwarebytes. It's simply all the Malwarebytes data from C:\ProgramData\Malwarebytes (virus database, build number, etc) inside an SFX .exe archive set to run a batch file after successful extraction.

The Problem

My existing updater works by copying each file with individual xcopy commands, but this time I want it to simply copy the whole folder. But when trying to xcopy to C:\ProgramData, I get "Access denied" for everything.

This occurs even though I'm using the /y and /o switches and running the .exe as Administrator (from the context menu) to achieve elevated permissions. I know that I'm hitting the right directory and that the update does work with a manual copy and paste of the folder. Is it just that it's not possible to command-copy a folder to ProgramData in Windows 7?

Extra Information

Inside the SFX .exe archive, I have a folder called "Malwarebytes" and a batch file. This is the only relevant segment of the batch file (I have independently confirmed that the rest of it works):

xcopy "Malwarebytes" "C:\ProgramData\Malwarebytes"\ /y /s /c /h /o

enter image description here


Solution

  • Odd.. It just started working.

    The only idea I have for this is that when I was trying this, I was trying it with an activated version of Malwarebytes, which means that it was running a service in the background, whereas this time I was not using an activated Malwarebytes'.

    This could have possibly been denying access to the files because they were in use.

    I don't know. Thanks anyway, guys.