How many materials truly have an infinite resistivity?
none. You can even get electrons to flow in a vacuum via thermionic emission.
The reason there is a spark is because you have several thousand volts built up and the resistivity of air is like 40KV/cm so once you get close enough they jump the gap to the door which is usually pretty close to earth ground.
I'm not sure about touching a windowpane and if that would help. I think if the windowpane had a ground clip, then it could absorb the charge with less of a spark since the total resistance to ground is higher, but it would depend on things like: the resistivity of the window pane, the caulk, how it's mounted, etc.
I just take the shock. It's not dangerous.
So in the "doorknob: case, air is the intermediate conductor. If you ohms law it out, if you have 3KV charge on a hand flowing through a door to ground (lets say 10 ohms or so) then that's 300A (for very briefly). What actually happens is that when you are very close to the knob (roughly 0.75mm for a 3KV charge) then the electrons will arc through the air to the doorknob causing a shock you feel.
I'm thinking of the windowpane has a very high resistance to ground (more than air-to-knob-to-ground) but still some electrical pathway touching it will allow the charge to dissipate with no arc through air.
You can easily build up millions of volts with plastics and other insulators. Look at how DIY van de graaff generators are made. But I think mostly static electricity is in the range of a few KV to tens of KV max. Low current of course so it's pretty safe.