Command & Conquer: Generals - Zero Hour

From LANCommander
Revision as of 19:58, 12 March 2024 by DoctorDalek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
EA Los Angeles
Publishers
Electronic ArtsAspyr Media
Release Date
Windows: September 22, 2003
Genres
Real Time Strategy (RTS)Strategy
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\generals.exe True
World Builder {InstallDir}\WorldBuilder.exe False

Install Script

$Key = $AllocatedKey -Replace "-", ""
$Documents = [Environment]::GetFolderPath('MyDocuments')

# 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 "$Documents\Command and Conquer Generals Zero Hour Data" -Recurse

Write-ReplaceContentInFile -Pattern '^Resolution = (.+)' -Substitution "Resolution = $X $Y" -FilePath "$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"

Uninstall Script

$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
$GeneralsPath = "$VirtualStore\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour"
$Documents = [Environment]::GetFolderPath('MyDocuments')

Remove-Item -Path "$GeneralsPath" -Recurse -Force
Remove-Item -Path "$Documents\Command and Conquer Generals Zero Hour Data" -Recurse -Force

Name Change Script

$Documents = [Environment]::GetFolderPath('MyDocuments')

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 "$Documents\Command and Conquer Generals Zero Hour Data\Network.ini"

Key Change Script

$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