Skip to content

Instantly share code, notes, and snippets.

@DylanPMunyard
Created February 24, 2026 13:08
Show Gist options
  • Select an option

  • Save DylanPMunyard/aa791733d55d5deef10c158e306287c5 to your computer and use it in GitHub Desktop.

Select an option

Save DylanPMunyard/aa791733d55d5deef10c158e306287c5 to your computer and use it in GitHub Desktop.
1942 on Linux

Battlefield 1942 on Arch

Installation

  1. Download the game

  2. Install with Wine

    wine installer.exe

    Installs to: ~/.wine/drive_c/EA Games/Battlefield 1942/

  3. CD KEY IN USE - Intermittently get this error joining a server. Fix was to generate a new key each launch. Adapted BF1942-MP-Enabler.exe to run as a console app without requiring input

using System;
using System.Linq;
using Microsoft.Win32;

internal class BF1942KeyGen
{
	private static void Main(string[] args)
	{
		string key = "BF1942" + GenerateRandomSerial(16);

		if (SaveKeyToRegistry(key))
		{
			Console.WriteLine("BF1942 key generated: " + key);
		}
		else
		{
			Console.WriteLine("Failed to save key to registry");
		}
	}

	private static string GenerateRandomSerial(int length)
	{
		Random random = new Random();
		const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		return new string(Enumerable.Range(0, length)
			.Select(_ => chars[random.Next(chars.Length)])
			.ToArray());
	}

	private static bool SaveKeyToRegistry(string key)
	{
		try
		{
			RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
			RegistryKey subkey = hklm.CreateSubKey("SOFTWARE\\Electronic Arts\\EA GAMES\\Battlefield 1942\\ergc", writable: true);
			subkey.SetValue(string.Empty, key);
			subkey.Close();
			return true;
		}
		catch (Exception)
		{
			return false;
		}
	}
}
  1. Compile app with Mono C# compiler sudo pacman -S mono && mcs BF1942KeyGen.cs && mv BF1942KeyGen.exe ~/.wine/drive_c/EA\ Games/Battlefield\ 1942/Tools

  2. Create launcher script Create launch.sh in the game directory: (runs the key gen every launch)

    #!/bin/bash
    cd "/home/dylan/.wine/drive_c/EA Games/Battlefield 1942"
    wine "./BF1942KeyGen.exe"
    wine "./BF1942.exe" +restart 1
    echo "Press Enter to close this window..."
    read

    Then: chmod +x launch.sh

  3. Create desktop file Create ~/.local/share/applications/battlefield-1942.desktop:

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Battlefield 1942
    Exec="/home/dylan/.wine/drive_c/EA Games/Battlefield 1942/launch.sh"
    Icon=/home/dylan/.wine/drive_c/EA Games/Battlefield 1942/bf1942.ico
    Categories=Game;
    Terminal=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment