@echo off
rem this script puts everything in place ...

set TOOLS=%SystemDrive%\tools
set SXS=%WINDIR%\sources\sxs
set BATCH=%TOOLS%\scripts\autoconfig.cmd
set LOG=%SystemDrive%\StartAutoconfig.txt

del /F %LOG% 1>nul 2>nul
if not "%1"=="STDOUT_TO_FILE" %0 STDOUT_TO_FILE %* 1>%LOG% 2>&1
shift /1

echo ####### %0 #######
date /t
time /t
echo.

rem WARNING: DO NOT KILL windows explorer here!
rem   Explanation: Doing this will result in a crippled
rem   windows defender configuration! (the app to open it will not be present)

echo copying folder %TOOLS% ...
robocopy tools %TOOLS% /MIR /256 /NJH /NFL /NDL
echo.

echo copying folder %SXS% ...
robocopy sources\sxs %SXS% /MIR /256 /NJH /NFL /NDL
echo.

echo setting permissions for [%TOOLS% ] ...
cd /D %SystemDrive%\
takeown /F %TOOLS% /R /A /D Y 1>nul
icacls %TOOLS% /inheritance:r
icacls %TOOLS% /grant Administrators:F /t /c /l 1>nul
icacls %TOOLS% /grant Users:RX /t /c /l 1>nul
echo.

echo starting %BATCH% ...
call %BATCH%
echo.

date /t
time /t
echo ####### %0 #######
echo READY.
echo.