EDIT: The below information is generally correct, but the location of the registry key changed, and I don't know where it is, ... Ancientman relocated the keys so no matter if a 32bit or 64 bit OS, the key is located in same place. .... But I can't look in my registry to check atm.
HAve you installed various types of BF2, i.e. installed both Steam and Retail DVD on same OS installation?
I must know what OS you have, I must know if it's 32 bit or 64 bit.
You have a missing or corrupt registry key,
on 64 bit machine:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\EA Games\Battlefield 2]
on 32 bit machine:
[HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts\EA Games\Battlefield 2]
There is a key that should list the BF2 installation directory.
I'm not in front of my PC with BF2 installed, I can't give you the exact key name ATM.
Fixing that should be all that is needed.
Hopefully someone else can respond with the exact key name.
Note that you must add your own unique installation directory D:\Program Files (x86)\... to the key.