I recall reading a forum somewhere where something like this was related to the master window switch. The fix was to clean the switch contacts the theory being that them being dirty resulted in excess resistance and that the current available when other things in the car were running was not enough to voltage/current to overcome this resistance. Sounds possible and might explain the working when not running but not when running. Also, are your battery, alternator and voltage regulator and grounds OK? Or maybe the window motor?