Battlefield 2

From LANCommander
Revision as of 02:02, 6 January 2024 by DoctorDalek (talk | contribs) (Created new page for Battlefield 2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Digital Illusions CE
Publishers
Electronic Arts
Release Date
Windows: June 21, 2005
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\bf2.bat True

Install Script

#######################################################################
#Updates Screen Resolution to match desktop resolution
#######################################################################

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

Set-Content -Path "$InstallDirectory\bf2.bat" -Value "bf2.exe +szx $($Display.Bounds.Width) +szy $($Display.Bounds.Height) +widescreen 1 +restart" -force

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$env:userprofile\Documents\Battlefield 2" -force -Recurse

#######################################################################

Uninstall Script

Remove-item -path "$env:userprofile\Documents\Battlefield 2" -recurse -force
Remove-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\EA Games\Battlefield 2" -force -recurse
Remove-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\EA Games\Battlefield 2 Special Forces" -force -recurse

Name Change Script

Write-ReplaceContentInFile -Pattern 'LocalProfile.setName "(.+)"' -Substitution "LocalProfile.setName ""$NewPlayerAlias""" -FilePath "$env:userprofile\Documents\Battlefield 2\Profiles\0001\Profile.con"
Write-ReplaceContentInFile -Pattern 'LocalProfile.setNick "(.+)"' -Substitution "LocalProfile.setNick ""$NewPlayerAlias""" -FilePath "$env:userprofile\Documents\Battlefield 2\Profiles\0001\Profile.con"
Write-ReplaceContentInFile -Pattern 'LocalProfile.setName "(.+)"' -Substitution "LocalProfile.setName ""$NewPlayerAlias""" -FilePath "$env:userprofile\Documents\Battlefield 2\Profiles\Default\Profile.con"
Write-ReplaceContentInFile -Pattern 'LocalProfile.setNick "(.+)"' -Substitution "LocalProfile.setNick ""$NewPlayerAlias""" -FilePath "$env:userprofile\Documents\Battlefield 2\Profiles\Default\Profile.con"

Key Change Script

New-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\EA Games\Battlefield 2\ergc"
New-ItemProperty -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Electronic Arts\EA GAMES\Battlefield 2\ergc" -Name "@" -Value "x9392$AllocatedKey" -Force
New-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\EA Games\Battlefield 2 Special Forces\ergc"
New-ItemProperty -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Electronic Arts\EA GAMES\Battlefield 2 Special Forcers\ergc" -Name "@" -Value "x9392$AllocatedKey" -Force