Command & Conquer: Generals - Zero Hour

From LANCommander
Revision as of 07:02, 31 July 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Release Date = {{Game.InfoBox.ReleaseDate|Windows|September 22, 2003}} | PCGamingWiki = Command_%26_Conquer:_Generals_-_Zero_Hour }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = generals.exe|Arguments = |WorkingDirectory = |Primary = True}} {{Game.ActionBox.Row|Name = World Builder|Path = WorldBuilder.exe|Arguments = |WorkingDirectory = |Primary = False}} }} {{Game.Scripts.Install |Name = Ins...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Release Date
Windows: September 22, 2003
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play generals.exe True
World Builder WorldBuilder.exe False

Install Script

This script requires admin access to function properly

$InstallDir = $PSScriptRoot
$Key = $args[0] -Replace "-", ""
Add-Type -AssemblyName System.Windows.Forms
$Display = ([System.Windows.Forms.Screen]::AllScreens | Where-Object Primary).Bounds

$X = $Display.Width
$Y = $Display.Height

function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
    $content = (Get-Content $FilePath) -replace $Regex, $Replacement
    [IO.File]::WriteAllLines($FilePath, $content)
}

$GeneralsPath = "HKLM:\SOFTWARE\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 "$InstallDir"
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 "$InstallDir\ProfileTemplate" -Destination "$($env:USERPROFILE)\Command and Conquer Generals Zero Hour Data" -Recurse

Write-ReplaceContentInFile -Regex '^Resolution = (.+)' -Replacement "Resolution = $X $Y" -FilePath "$($env:USERPROFILE)\Command and Conquer Generals Data Zero Hour\options.ini"

Name Change Script

$NewName = $args[0]

if ($NewName.Length -gt 11) {
    $NewName = $NewName.Substring(0, 11);
}

$NetworkPrefsFormattedName = ""

foreach ($character in $NewName.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

Key Change Script

This script requires admin access to function properly

$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Command and Conquer Generals Zero Hour"

$Key = $args[0] -Replace "-", ""

Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key