Windows cf-upgrade self-exec fix.

All of which is, of course, pre-existing; I'm entirely happy to merge what you have - let me know if you want to get tangled up in fixing the other defects of this code as well.  Just be warned that you'll probably find that the more you pull on that thread of horror, the more it'll unravel yet worse monstrosities.