I'm not sure of the duration but remove the ground wire to the battery for a long while. Try 1 minute, 30 minutes, etc...
When I first got my 300TE the previous owner didn't know why the 4MATIC light was always on.
I left the battery disconnected for 45 minutes while I was polishing the car.
Reconnected it, lights gone out and hasn't come on since.
Note: If you don't know when the last time the filter and fluid has been changed in the transmission, do it now. Also replace sensors in dif' and or wheels. Wouldn't hurt to have the Electronic Accelerator Control checked out. Typically the wire harnesses go bad on them.
I had a 93 400E with ASR (has the same V8 4.2 liter engine. Ignition cap n rotor. Yours probably has coil packs). Fortunately, I didn't have any problems with it at 160k miles. Though rewired the 1st gear over ride to the rear window's lock out switch. (since it defaults to 2nd at stops). Also gives you an extra kickdown gear on the fly. * Not recommended over 50 mph *.
A minor upgrade thanks to 2Phast's W124 site.