File Synchronizations and/or Script cannot copy files to system32 folder
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
exit
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.
Answers (2)
"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
Comments:
-
or run a script to take control and then file sync should work - SMal.tmcc 5 years ago
Hey guys,
So I ran into this issue when trying to copy to System32\GroupPolicy folder. Here's what I did rather than taking ownership.
Script Type: Can be an Online Kscript or offline kscript
Windows Run AS: Local System
Directory: windir%\sysnative
File: xcopy.exe
Parameters: $(KACE_DEPENDENCY_DIR)\* C:\Windows\System32\GroupPolicy\ /s /e /v /i /h /y