Clean and Scrape Before You Paint
It seems counterintuitive to clean the windows first. But it's a good idea for two reasons. First, your paint job will last longer if the intersection of the glass and wood sash is sealed with paint. You can't get a good seal if the glass is dirty. Second, you'll get a neater paint job if you scrape off previous layers of paint and other crud that may be on the glass.
Use any window washing solution you prefer and a new, single-edge blade to clean old paint and gunk from the glass. Apply the solution, then scrape, to avoid scraping on dry glass. Never scrape dry glass. Grit pushed by the razor can scratch the window.
Remove the Sash
It's quicker and easier to paint the sash if you take it out of the window frame and rest it on sawhorses or a workbench. The sashes in most modern double-hung, sliding and casement windows are removable. The photo shows removing a casement sash. Most newer double-hung windows are removable by pivoting them in and twisting to release them. Old double-hung windows that are held in by wooden stops are more difficult to remove. It may not be worth the effort unless you're a perfectionist.