Command & Conquer: Generals: Difference between revisions

From LANCommander
(Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Release Date = {{Game.InfoBox.ReleaseDate|Windows|February 10, 2003}} | PCGamingWiki = Command_%26_Conquer:_Generals }} {{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 = Install Script |...")
 
(Fixes to deprecated PowerShell scripts)
Line 2: Line 2:
{{Game.InfoBox
{{Game.InfoBox
|Cover = cover.jpg
|Cover = cover.jpg
|Developers =
{{Game.InfoBox.Developer|EA Pacific}}
|Publishers =
{{Game.InfoBox.Developer|Electronic Arts}}{{Game.InfoBox.Developer|Aspyr Media}}
|Release Date =
|Release Date =
{{Game.InfoBox.ReleaseDate|Windows|February 10, 2003}}
{{Game.InfoBox.ReleaseDate|Windows|February 10, 2003}}
| PCGamingWiki = Command_%26_Conquer:_Generals
|Genres =
}}
{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}{{Game.InfoBox.Genre|Strategy}}
|PCGamingWiki = Command_%26_Conquer:_Generals}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Play|Path = generals.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play|Path = {InstallDir}\generals.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = World Builder|Path = WorldBuilder.exe|Arguments = |WorkingDirectory = |Primary = False}}
{{Game.ActionBox.Row|Name = World Builder|Path = {InstallDir}\WorldBuilder.exe|Arguments = |WorkingDirectory = |Primary = False}}
}}
}}


{{Game.Scripts.Install
{{Game.Scripts.Install
Line 17: Line 23:
|Description =  
|Description =  
|RequiresAdmin = True
|RequiresAdmin = True
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$InstallDir = $PSScriptRoot
<syntaxhighlight lang="powershell" line>
$Key = $args[0] -Replace "-", ""
$Key = $AllocatedKey -Replace "-", ""
# Accessible via $Display.Width and $Display.Height
Add-Type -AssemblyName System.Windows.Forms
$Display = ([System.Windows.Forms.Screen]::AllScreens | Where-Object Primary).Bounds


$X = $Display.Width
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Y = $Display.Height
$Display = Get-PrimaryDisplay


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


$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"
$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"
Line 38: Line 38:
New-Item -Path "$GeneralsPath\ergc" -Force
New-Item -Path "$GeneralsPath\ergc" -Force


New-ItemProperty -Path "$GeneralsPath" -Name "InstallPath" -Value "$InstallDir"
New-ItemProperty -Path "$GeneralsPath" -Name "InstallPath" -Value "$InstallDirectory\"
New-ItemProperty -Path "$GeneralsPath" -Name "Language" -Value "english"
New-ItemProperty -Path "$GeneralsPath" -Name "Language" -Value "english"
New-ItemProperty -Path "$GeneralsPath" -Name "MapPackVersion" -Value 65536
New-ItemProperty -Path "$GeneralsPath" -Name "MapPackVersion" -Value 65536
Line 44: Line 44:
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key


Copy-Item -Path "$InstallDir\ProfileTemplate" -Destination "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data" -Recurse
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data" -Recurse


Write-ReplaceContentInFile -Regex '^Resolution = (.+)' -Replacement "Resolution = $X $Y" -FilePath "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data\options.ini"
Write-ReplaceContentInFile -Pattern '^Resolution = (.+)' -Substitution "Resolution = $X $Y" -FilePath "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data\options.ini"
</syntaxhighlight>
</syntaxhighlight>
}}
}}
           
{{Game.Scripts.Uninstall
|Name = Uninstall Script
|Description =
|RequiresAdmin = True
|Contents =
<syntaxhighlight lang="powershell" line>
$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"


Remove-Item -Path "$GeneralsPath" -recurse -Force
Remove-Item -Path "$env:USERPROFILE\Documents\Command and Conquer Generals Data" -Recurse -force
</syntaxhighlight>
}}
           
{{Game.Scripts.NameChange
{{Game.Scripts.NameChange
|Name = Name Change Script
|Name = Name Change Script
|Description =  
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$NewName = $args[0]
<syntaxhighlight lang="powershell" line>
 
if ($NewPlayerAlias.Length -gt 11) {
if ($NewName.Length -gt 11) {
     $NewPlayerAlias = $NewPlayerAlias.Substring(0, 11);
     $NewName = $NewName.Substring(0, 11);
}
}


$NetworkPrefsFormattedName = ""
$NetworkPrefsFormattedName = ""


foreach ($character in $NewName.ToCharArray()) {
foreach ($character in $NewPlayerAlias.ToCharArray()) {
     $NetworkPrefsFormattedName = $NetworkPrefsFormattedName + $character + "_00"
     $NetworkPrefsFormattedName = $NetworkPrefsFormattedName + $character + "_00"
}
}
Line 85: Line 98:
</syntaxhighlight>
</syntaxhighlight>
}}
}}
 
           
{{Game.Scripts.KeyChange
{{Game.Scripts.KeyChange
|Name = Key Change Script
|Name = Key Change Script
|Description =  
|Description =  
|RequiresAdmin = True
|RequiresAdmin = True
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
<syntaxhighlight lang="powershell" line>
$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"
$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"


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


Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Revision as of 02:05, 6 January 2024

Developers
EA Pacific
Publishers
Electronic ArtsAspyr Media
Release Date
Windows: February 10, 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

This script requires admin access to function properly

$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

$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"

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 "Version" -Value 65544
Set-ItemProperty -Path "$GeneralsPath\ergc" -Name "(Default)" -Value $Key

Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data" -Recurse

Write-ReplaceContentInFile -Pattern '^Resolution = (.+)' -Substitution "Resolution = $X $Y" -FilePath "$($env:USERPROFILE)\Documents\Command and Conquer Generals Data\options.ini"

Uninstall Script

This script requires admin access to function properly

$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"

Remove-Item -Path "$GeneralsPath" -recurse -Force
Remove-Item -Path "$env:USERPROFILE\Documents\Command and Conquer Generals Data" -Recurse -force

Name Change Script

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 Data"

Set-Content "$($env:USERPROFILE)\Command and Conquer Generals Data\Network.ini" $NetworkPrefsIni

$SkirmishIni = @"
Color = -1
FPS = 30
Map = maps\alpine assault\alpine assault.map
PlayerTemplate = -1
SlotList = M=03maps/alpine assault;MC=B7E74B8C;MS=275524;SD=71090984;C=100;S=HPats-Desktop,0,0,TT,-1,-1,-1,-1,1:CE,-1,-1,-1,-1:O:O:O:O:O:O:;
UserName = $NetworkPrefsFormattedName
"@

Set-Content "$($env:USERPROFILE)\Command and Conquer Generals Data\Skirmish.ini" $SkirmishIni

Key Change Script

This script requires admin access to function properly

$GeneralsPath = "HKLM:\SOFTWARE\WOW6432Node\Electronic Arts\EA Games\Generals"

$Key = $AllocatedKey -Replace "-", ""

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