$Display = Get-PrimaryDisplay
$AppData = [Environment]::GetFolderPath('ApplicationData')
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"

New-Item "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts" -Force
New-Item "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Force
New-Item "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\ergc" -Force
New-Item "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Force
New-Item "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Language' -Value 'english' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'InstallPath' -Value "$InstallDirectory\" -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Version' -Value 131073 -PropertyType DWord -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'MapPackVersion' -Value 131072 -PropertyType DWord -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'UseLocalUserMaps' -Value 0 -PropertyType DWord -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'UserDataLeafName' -Value 'My The Lord of the Rings, The Rise of the Witch-king Files' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\ergc" -Name '(default)' -Value '' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'DisplayName' -Value 'The Lord of the Rings, The Rise of the Witch-king' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Installed From' -Value 'F:\' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Registration' -Value 'SOFTWARE\Electronic Arts\Electronic Arts\ergc' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'CacheSize' -Value '3139187712' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'SwapSize' -Value '0' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Language' -Value 'English UK' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Locale' -Value 'en_uk' -PropertyType String -Force 
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'CD Drive' -Value 'F:\' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Install Dir' -Value "$InstallDirectory" -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Product GUID' -Value '{B931FB80-537A-4600-00AD-AC5DEDB6C25B}' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Region' -Value 'NorthAmerica' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Folder' -Value 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Patch URL' -Value 'http://transtest.ea.com/Electronic Arts/The Battle for Middle-earth 2/NorthAmerica' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Name 'Suppression Exe' -Value 'rtsi.exe' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0" -Name 'Language' -Value 19 -PropertyType DWord -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0" -Name 'DisplayName' -Value 'The Lord of the Rings, The Rise of the Witch-king' -PropertyType String -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king\1.0" -Name 'LanguageName' -Value 'English UK' -PropertyType String -Force

New-Item -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe"
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "Game Registry" -Value "SOFTWARE\Electronic Arts\The Lord of the Rings, The Rise of the Witch-king" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "Restart" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "DirectX Installed" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "Installed" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "@" -Value "$InstallDirectory\lotrbfme2ep1.exe" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lotrbfme2ep1.exe" -Name "Path" -Value "$InstallDirectory\" -Force

Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$AppData\My The Lord of the Rings, The Rise of the Witch-king Files" -Recurse -Force

Write-ReplaceContentInFile -Pattern '^Resolution = (.+)' -Substitution "Resolution = $($Display.Bounds.Width) $($Display.Bounds.Height)" -FilePath "$AppData\My The Lord of the Rings, The Rise of the Witch-king Files\Options.ini"

# Skip Intros
Remove-Item -Path "$InstallDirectory\The Lord of the Rings, The Rise of the Witch-king\data\movies\CS01.vp6"
Remove-Item -Path "$InstallDirectory\The Lord of the Rings, The Rise of the Witch-king\data\movies\TE_LOGO.vp6"
Remove-Item -Path "$InstallDirectory\The Lord of the Rings, The Rise of the Witch-king\data\movies\NewLineLogo.vp6"
Remove-Item -Path "$InstallDirectory\The Lord of the Rings, The Rise of the Witch-king\data\movies\NLC_LOGO.vp6"
Remove-Item -Path "$InstallDirectory\The Lord of the Rings, The Rise of the Witch-king\data\movies\EALogo.vp6"