none
SCCM 2012 copying folder or contents

    Question

  • Hello, I am having issues in copying contents from DP to target machine. What I am doing is adding a task sequence which will run a batch file, contents below.

    @echo off

    :: Take ownership of original
    TakeOwn.exe /F %SystemRoot%\system32\oobe

    :: Replaces acls with default inherited acls
    icacls %SystemRoot%\system32\oobe /reset

    :: create folders in C:\windows\system32

    MKDIR "C:\Windows\System32\oobe\info\backgrounds"

    :: copy *.jpg from a folder to newly created folder

    XCOPY "%~dp0Pics\*.jpg" "C:\Windows\System32\oobe\info\backgrounds\" /Y

    :: return exit code to SCCM

    exit /b %EXIT_CODE%

    After the OS is fully deployed I don't see any folder created or contents copied to that folder. What am I doing wrong? Help!!

    Even tried "%windir%\System32\oobe\" instead of "C:\windows\system32\oobe" but that too failed. Should I use %systemroot%? 

    This step is during post sysprep step so to run once OS is deployed.


    Update 1: tried %systemroot% & it failed again. Not sure why configmgr is failing to create a folder. The command works fine on a local machine.

    • Edited by strike3test Thursday, August 01, 2013 4:42 AM more info
    Thursday, August 01, 2013 2:54 AM

Answers

  • Does it do what you're expecting if you run the script manually? Also, are you sure that it's being run in x64 mode during the TS?

    One other thing, did you try out the sysnative trick I linked to above? I have to use this for a few of my scripts during a couple of my OSD task sequences, so it might be worth a try.


    Don't retire TechNet!

    • Marked as answer by strike3test Tuesday, August 13, 2013 1:15 AM
    Wednesday, August 07, 2013 5:28 AM

All replies

  • It failed with which exit code?
    You are using %EXIT_CODE% in the batch but that variable was not defined anywhere. %errorcode% does exist by default though. Double check if
    the folder was created in SysWOW64.

    Torsten Meringer | http://www.mssccmfaq.de

    Thursday, August 01, 2013 7:01 AM
    Moderator
  • Instead of using %systemroot%\system32, try using %systemroot%\sysnative instead.

    http://www.nynaeve.net/?p=133


    Don't retire TechNet!

    Thursday, August 01, 2013 2:30 PM
  • Thanks Torsten, rightly said about exit code. Didn't set, didn't get. I am running this command as command line option TS.

    cmd /c Takeown.exe /F %systemroot%\System32\oobe & cmd /c MKDIR "%systemroot%\System32\oobe\info\backgrounds"

    Hopefully it works, if it does then I will create a package with the pics I want to be copied to that folder & add that package. If it doesn't you will hear from me again.


    Thursday, August 01, 2013 8:59 PM
  • So running the command as command line TS works, creates the folder in right place & now comes the task of copying files to that folder. Does this command looks about right?

    if exist "%WINDIR%\System32\oobe\info\backgrounds\" COPY /Y "%~dp0pics/*.jpg" "%WINDIR%\System32\oobe\info\backgrounds\"

    Edit 1: didn't work, folder created but contents didn't copy. :-( May be permissions are at play.





    • Edited by strike3test Friday, August 02, 2013 3:39 AM edit
    Friday, August 02, 2013 2:01 AM
  • Copying contents for some reason fails. Didn’t imagine the whole thing is this complicated. For some reason create folder command will not create folder if run from batch file but works if don’t from command line TS. Second, copying just isn’t working at all. Won’t copy a thing, I have checked the syntax but didn’t find anything wrong with it. Is it possible to do the whole create folder plus copy contents in Winpe environment? 

    Monday, August 05, 2013 12:16 AM
  • Why are prefacing takeown.exe with cmd? It's a stand-alone executable.

    Were in the TS are you doing the above?

    For your copy command and %~dp0, you have a *forward* slash after %~dp0? That may be throwing the copy command off as it's certainly not necessary. %~dp0 already includes a trailing *backslash*.


    Jason | http://blog.configmgrftw.com

    Monday, August 05, 2013 1:33 AM
  • Thanks Jason, now I am attempting the whole thing via batch file.

    TakeOwn.exe /F %systemroot%\System32\oobe
    ICACLS %systemroot%\System32\oobe /reset
    if not exist "%systemroot%\System32\oobe\info\backgrounds" MKDIR "%systemroot%\System32\oobe\info\backgrounds"
    copy /y "%~dp0Pics\*.*" "%systemroot%\System32\oobe\info\backgrounds\"

    exit /b

    regarding copy /y "%~dp0Pics\*.*" 

    Pics is a folder on share & within are all the JPG files which I need to copy to %systemroot%\System32\oobe\info\backgrounds\"

    Do you think the command will work?

    Monday, August 05, 2013 4:53 AM

  • Do you think the command will work?

    Just try it and you will see the result.
    The copy command will work if there's a subfolder \Pics in the directory where the script was started from.

    Torsten Meringer | http://www.mssccmfaq.de

    Monday, August 05, 2013 7:00 AM
    Moderator
  • My current script looks like this which for some reason isn't working. Please can someone have a quick look at it & point the error.

    TakeOwn.exe /F %systemroot%\System32\oobe
    ICACLS %systemroot%\System32\oobe /reset
    if not exist "%systemroot%\System32\oobe\info\backgrounds" MKDIR "%systemroot%\System32\oobe\info\backgrounds"
    COPY /Y %~dp0Pics\*.jpg" "%systemroot%\System32\oobe\info\backgrounds\"
    REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" /v "OEMBackground" /d 1 /t REG_DWORD /f

    exit /b 


    Tuesday, August 06, 2013 9:54 PM
  • Hi,

    Have you checked to see if your folders are being created in the SysWOW64 folder instead?


    Don't retire TechNet!

    Tuesday, August 06, 2013 11:16 PM
  • Hi Mike, yes I have checked SYSWOW64, sadly it ain't there 
    Wednesday, August 07, 2013 4:05 AM
  • Does it do what you're expecting if you run the script manually? Also, are you sure that it's being run in x64 mode during the TS?

    One other thing, did you try out the sysnative trick I linked to above? I have to use this for a few of my scripts during a couple of my OSD task sequences, so it might be worth a try.


    Don't retire TechNet!

    • Marked as answer by strike3test Tuesday, August 13, 2013 1:15 AM
    Wednesday, August 07, 2013 5:28 AM