$Key = $AllocatedKey -Replace "-", ""
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay
$X = $Display.Bounds.Width
$Y = $Display.Bounds.Height
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
$GeneralsPath = "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour"
New-Item -Path "$GeneralsPath" -Force
New-Item -Path "$GeneralsPath\ergc" -Force
New-ItemProperty -Path "$GeneralsPath" -Name "InstallPath" -Value "$InstallDirectory"
New-ItemProperty -Path "$GeneralsPath" -Name "Language" -Value "english"
New-ItemProperty -Path "$GeneralsPath" -Name "MapPackVersion" -Value 65536
New-ItemProperty -Path "$GeneralsPath" -Name "Proxy" -Value ""
New-ItemProperty -Path "$GeneralsPath" -Name "UserDataLeafName" -Value "Command and Conquer Generals Zero Hour Data"
New-ItemProperty -Path "$GeneralsPath" -Name "Version" -Value 65540
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$($env:USERPROFILE)\Documents\Command and Conquer Generals Zero Hour Data" -Recurse
Write-ReplaceContentInFile -Pattern '^Resolution = (.+)' -Substitution "Resolution = $X $Y" -FilePath "$env:USERPROFILE\Documents\Command and Conquer Generals Data Zero Hour\options.ini"
Rename-Item -Path "$InstallDirectory\Data\English\Movies\EA_LOGO.BIK" -NewName "$InstallDirectory\Data\English\Movies\EA_LOGO.BIK.bak"
Rename-Item -Path "$InstallDirectory\Data\English\Movies\EA_LOGO640.BIK" -NewName "$InstallDirectory\Data\English\Movies\EA_LOGO640.BIK.bak"
Rename-Item -Path "$InstallDirectory\Data\English\Movies\sizzle_review.bik" -NewName "$InstallDirectory\Data\English\Movies\sizzle_review.bik.bak"
Rename-Item -Path "$InstallDirectory\Data\English\Movies\sizzle_review640.bik" -NewName "$InstallDirectory\Data\English\Movies\sizzle_review640.bik.bak"
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
$GeneralsPath = "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour"
Remove-Item -Path "$GeneralsPath" -Recurse -Force
Remove-Item -Path "$($env:USERPROFILE)\Documents\Command and Conquer Generals Zero Hour Data" -Recurse -Force
if ($NewPlayerAlias.Length -gt 11) {
$NewPlayerAlias = $NewPlayerAlias.Substring(0, 11);
}
$NetworkPrefsFormattedName = ""
foreach ($character in $NewPlayerAlias.ToCharArray()) {
$NetworkPrefsFormattedName = $NetworkPrefsFormattedName + $character + "_00"
}
$NetworkPrefsIni = "UserName = $NetworkPrefsFormattedName"
Write-ReplaceContentInFile -Pattern '^UserName = (.+)' -Substitution "$NetworkPrefsIni" -FilePath "$env:USERPROFILE\Documents\Command and Conquer Generals Zero Hour Data\Network.ini"
#if ($NewPlayerAlias.Length -gt 11) {
# $NewPlayerAlias = $NewPlayerAlias.Substring(0, 11);
#}
#
#$NetworkPrefsFormattedName = ""
#
#foreach ($character in $NewPlayerAlias.ToCharArray()) {
# $NetworkPrefsFormattedName = $NetworkPrefsFormattedName + $character + "_00"
#}
#
#$NetworkPrefsIni = "UserName = $NetworkPrefsFormattedName"
#
#New-Item -ItemType Directory -Force -Path "$($env:USERPROFILE)\Command and Conquer Generals Zero Hour Data"
#
#Set-Content "$($env:USERPROFILE)\Command and Conquer Generals Zero Hour Data\Network.ini" $NetworkPrefsIni
#
#$SkirmishIni = @"
#FPS = 30
#Map = maps\alpine assault\alpine assault.map
#PlayerTemplate = -1
#SlotList = US=1;M=03maps/alpine assault;MC=DEA9E8E4;MS=275491;SD=72545281;C=100;SR=0;SC=10000;O=N;S=HDoctorDalek,0,0,TT,-1,-1,-1,-1,1:CE,-1,-1,-1,-1:O:O:O:O:O:O:;
#StartingCash = 10000
#SuperweaponRestrict = No
#UserName = $NetworkPrefsFormattedName
#"@
#
#Set-Content "$($env:USERPROFILE)\Command and Conquer Generals Zero Hour Data\Skirmish.ini" $SkirmishIni
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
$GeneralsPath = "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour"
$Key = $AllocatedKey -Replace "-", ""
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key