Here's what I do or have done to have the energy, courage, and drive to keep writing, in semi-order of importance:
Have an opinion
Find an important reason to write, an important message.
If you have none, go to your core values (if you don't know them, there are tests online).
Read magazines (e.g., Amnesty Press, the WWF magazine) and watch TV shows and movies. I think it needs to be current issues even if you're not writing a contemporary text.
You're finding your reason to write, not what to write.
If you consume media whose opinions you share you'll get more meat on the bones for your message. If you consume things you disagree with, you might also strengthen your message by counter argumenting.
Don't be afraid to have an opinion.
Study the craft of writing
Sometimes stories don't work because you've built them wrong from the beginning. Most of the time they can be fixed, if you know how to.
In order to do that you need to study the craft of writing.
I only know how I do it, but I've figured between the lines that others follow similar paths. (For instance, many successful authors started out as journalists...)
I firmly believe the knowledge of how to write is something you learn, for the rest of your life.
Think of it as learning to ride a bike. Once you've got it, you can't explain what muscles you need to keep balance, and most of the time not even how to push the pedals (or, I realized a few years back, pull them if you have the right type of shoes and pedals).
It takes determination, seeing, and trying, and for most people, more time and effort than they can or are willing to put into it...
Even such fleeting things as voice follow the same principle. See it. Try it. After enough attempts, you get it.
Maybe you need to learn how to finish a story, be it a crappy story or not? A test says more than a thousand theories... so finish it even if your inner critic is kicking and screaming...
Some craft I've been helped by
Story structure and character arcs were two very important discoveries early in my writing life. (I remember being awed by movies and TV shows after having read Syd Fields "Screenplay" and then seeing the screen go dark at exactly one quarter, half time, and three quarters. Sometimes I don't even think I paid attention to what the movie was about...)
I suggest Weiland's texts on both as an introduction. She's good at getting you all excited about the subject so you can then go on and find complementary sources.
Another thing that helps me is to base the story on the conflict between a truth and a lie. The antagonist believes in the lie, the protagonist may also believe in the lie, but then come to believe in the truth and gets to pay dearly for it.
The choice of truths and lies will usually be based on some form of thematical intuition or notion and going back from the theme might produce more truths and lies for secondary characters to embrace as counterpoints or variations on the theme.
Emotional wounds have also done great for my stories. It's happened more than once that adding a wound to one character will inevitably add wounds to other characters and it may even bind them together and just having that event in the past will create tension and drama.
Adhesive is another great thing mentioned by James Scott Bell. Adhesive is what keeps characters in the place and the story (e.g., they're kidnapped, they're on a trip in a foreign country, one must catch the other and the other will get executed if he's caught, they are parent and child).
Without adhesive, the characters will just up and leave, or at least should.
A story with little or no adhesive will suffer tremendously because you want to write a whole novel, right? So the characters can't give up and leave, so you find all sorts of artificial reasons to keep them in the room, while a proper lock on the door from the start would have done wonders.
To figure out how all this works, I suggest reading tons of books and watching tons of movies and TV shows to immerse yourself in the craft of storytelling, and all the rest.
The only thing I've noticed you cannot trust writers of novels and scripts to help you understand is how to write... I.e. the exact process of writing. I can't for the life of me understand why so many literary and filmed works about the writing process show some guy punching away on the typewriter, send the first draft to the publisher and get instant fame. Maybe they're afraid to be replaced?
The solution is out there
Adopt a "the solution is out there"-attitude to problems, both in writing and life as a whole.
When you get problems to solve, don't look at yourself as a janitor that has to wipe the crap off the walls.
Look at yourself as a Sherlock Holmes searching for a solution.
If you look for problems, you'll find problems. If you look for solutions, you'll find solutions.
It also helps to be a bit zen about problems. So you have a problem... likely you should do some menial task to let your brain rest and reorganize itself and spit out the answer.
I can't count the number of times some hand washing the dishes has relaxed me to get the problem solved (so much so I'm seriously not considering getting a dishwasher...)
Write crappy first drafts
Write crappy first drafts and edit them into shape afterward.
Let high quality be a question for editing.
You need a ton of handwavium for the plot that's falling apart and a blind eye for the ridiculously dum sentences, but at this point, you're panning for gold, and finding a nugget requires digging through tons of dirt.
This is true even if you're an outliner.
The first draft is a pilot, a concept, there to prove or disprove that your idea can be turned into a story.
It's a block of marble very roughly cut into the shape you finally want.
Before you've written the first draft and can take a step back to discover that shape there is no use in polishing.
Listen to the story/your unconscious storyteller mind
Don't worry if things seem to go awry at the moment. Trust the story and your unconscious that you know more about where the text is going than you're aware of...
While psychologists don't agree with Freud's implicit notion that the unconscious is somehow "under us" as in "sub-" most agree that there's more to the mind than what we are aware of.
This is very true when it comes to writing.
Don't even trust your inner critic to know where it will all end... Go there and figure it out for yourself!