@echo off
cd /d "%~dp0"
%windir%\system32\reg.exe query "HKU\S-1-5-19" 1>nul 2>nul || goto :eof
for /f "tokens=4,5 delims=[]. " %%G in ('ver') do set _ver=%%G.%%H
if %_ver% NEQ 10.0 (
echo ============================================================
echo ERROR: This pack is for Windows 10 systems.
echo ============================================================
echo.
echo.
echo Press any key to exit...
pause >nul
goto :eof
)
if exist %windir%\ehome\ehshell.exe (
echo ============================================================
echo ERROR: MediaCenter pack is already installed.
echo ============================================================
echo.
echo.
echo Press any key to exit...
pause >nul
goto :eof
)
echo.
echo Copy files...
%windir%\system32\dism.exe /Quiet /Apply-Image /ImageFile:MediaCenter.wim /Index:1 /ApplyDir:%SystemDrive%\ 
echo.
echo Install assemblies...
set _ngen=%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe
%_ngen% install "Microsoft.MediaCenter.Mheg, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiwmp, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.Bml, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcstoredb, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.iTv.Hosting, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcstore, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcglidhostobj, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiiTV, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcepg, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.iTV.Media, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehshell, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehCIR, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehexthost, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.Playback, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiVidCtl, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiUserXp, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "loadmxf, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiActivScp, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.Sports, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.Interop, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.TV.Tuners.Interop, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiExtens, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcupdate, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiWUapi, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.ITVVM, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiTVMSMusic, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiProxy, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "BDATunePIA, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.Shell, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcplayerinterop, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiBmlDataCarousel, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiUPnP, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.UI, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Mcx2Dvcs, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.iTV, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehRecObj, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
set _ngen=%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe
%_ngen% install "BDATunePIA, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "mcstoredb, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehexthost32, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "ehiExtens, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
%_ngen% install "Microsoft.MediaCenter.UI, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=msil" /NoDependencies /queue:1 >nul 2>&1
echo.
echo Create services...
sc create ehRecvr binPath= "%systemroot%\ehome\ehRecvr.exe" error= ignore start= demand type= own DisplayName= "@%SystemRoot%\ehome\ehrecvr.exe,-101" depend= RPCSS obj= "NT AUTHORITY\networkService"
sc create ehSched binPath= "%systemroot%\ehome\ehsched.exe" error= ignore start= demand type= own DisplayName= "@%SystemRoot%\ehome\ehsched.exe,-101" depend= RPCSS obj= "NT AUTHORITY\networkService"
sc create Mcx2Svc binPath= "%SystemRoot%\system32\svchost.exe -k LocalServiceAndNoImpersonation" error= normal start= demand type= share DisplayName= "@%SystemRoot%\ehome\ehres.dll,-15501" depend= SSDPSRV/DeviceAssociationService/TermService/fdphost obj= "NT Authority\LocalService"
echo.
echo Update registry settings...
%windir%\system32\reg.exe import Install.reg >nul 2>&1
echo.
echo Create schedule tasks...
rmdir /s /q "%SystemRoot%\System32\Tasks\Microsoft\Windows\Media Center" >nul 2>&1
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Media Center" /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\ActivateWindowsSearch" /xml Tasks\ActivateWindowsSearch.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\ConfigureInternetTimeService" /xml Tasks\ConfigureInternetTimeService.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\DispatchRecoveryTasks" /xml Tasks\DispatchRecoveryTasks.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\ehDRMInit" /xml Tasks\ehDRMInit.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\InstallPlayReady" /xml Tasks\InstallPlayReady.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\mcupdate" /xml Tasks\mcupdate.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\MediaCenterRecoveryTask" /xml Tasks\MediaCenterRecoveryTask.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\ObjectStoreRecoveryTask" /xml Tasks\ObjectStoreRecoveryTask.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\OCURActivate" /xml Tasks\OCURActivate.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\OCURDiscovery" /xml Tasks\OCURDiscovery.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PBDADiscovery" /xml Tasks\PBDADiscovery.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PBDADiscoveryW1" /xml Tasks\PBDADiscoveryW1.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PBDADiscoveryW2" /xml Tasks\PBDADiscoveryW2.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PeriodicScanRetry" /xml Tasks\PeriodicScanRetry.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PvrRecoveryTask" /xml Tasks\PvrRecoveryTask.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\PvrScheduleTask" /xml Tasks\PvrScheduleTask.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\RecordingRestart" /xml Tasks\RecordingRestart.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\RegisterSearch" /xml Tasks\RegisterSearch.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\ReindexSearchRoot" /xml Tasks\ReindexSearchRoot.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\SqlLiteRecoveryTask" /xml Tasks\SqlLiteRecoveryTask.xml /f >nul 2>&1
schtasks /create /tn "\Microsoft\Windows\Media Center\UpdateRecordPath" /xml Tasks\UpdateRecordPath.xml /f >nul 2>&1
echo.
echo Set registry access permissions...
SetACL -on "HKLM\SOFTWARE\Classes\AppID\{0E11CB54-4C4A-4B37-AE0B-E93CEE60E646}" -ot reg -actn restore -bckp .\AclClass >nul 2>&1
SetACL -on "HKLM\SOFTWARE\Microsoft\MediaCenterPeripheral\ImageDownloadTable" -ot reg -actn restore -bckp .\AclSoft >nul 2>&1
SetACL -on "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Media Center\Display Settings" -ot reg -actn restore -bckp .\AclSoftWow >nul 2>&1
SetACL -on "HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Media Center" -ot reg -actn restore -bckp .\AclSys >nul 2>&1
echo.
echo.
echo Done.
echo.
echo Press any key to exit.
pause >nul
exit