Scripting Question

File Synchronizations and/or Script cannot copy files to system32 folder

01/23/2019 1015 views

No matter what I try, either script or file synch, I can't get a file to copy over into the C:\windows\system32 folder. Status shows it goes successfully, but the file is no where to be seen. For example: 

@echo off

xcopy OEMDefaultAssociations.xml C:\

move OEMDefaultAssociations.xml C:\windows\system32

del C:\OEMDefaultAssociations.xml


That's the above batch command I'm running in Script - if i change the folder to anything other than system32, like C:\temp, for example, it works. Whats the deal? I've tried with all credentials as well, local admin, domain admin etc.

Anyone have any suggestions/ideas, thanks.

0 Comments   [ + ] Show comments


All Answers


"system" owns the existing file in system32 and you need to take control of that file first.

takeown /f c:\windows\system32\OEMDefaultAssociations.xml /a
icacls c:\windows\system32\OEMDefaultAssociations.xml /grant everyone:F /c
rename c:\windows\system32\OEMDefaultAssociations.xml OEMDefaultAssociationsold.xml

xcopy your file.

Also FYI you are using a move command so no need to delete the move actually does a "copy and delete" function

Answered 01/23/2019 by: SMal.tmcc
Red Belt

  • or run a script to take control and then file sync should work
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ