Look in the Event Viewer and see what errors are showing up at the time that this is happening. Each error will have its own date and time shown.
Start> right click on My Computer> Manage> Event Viewer.
On the right side of the page you will see the options Applications, Security, and Systems, double click on Systems. There are eight columns on this page, the three that you will want are Type, Date, Time, and Event.
The errors will appear in the Type column, they are red dots with a white X inside of them.
Warnings will appear as a yellow trinangle with an exclamation mark inside.
When you see an error, double click on it and see what the description is.
Please post the error code/s found in the Event column and the descriptions back in this topic.
you can post the whole error box, click on the third icon down, that looks like an open book, this will copy to clipboard, open reply here and right click in reply box and choose paste, error will appear.
====
Also, since you have performed ungraceful shutdowns you could have corrupted the system so you should run checkdisk with the /r parameter at least twice:
http://support.microsoft.com/kb/315265/en-us
How to perform checkdisk
if you do not have Recovery Console installed, then run from the start menu
go to start, run, type in cmd
in cmd type in chkdsk c: /r and press enter
type Y for yes and press enter
type exit and press enter
restart pc, allow checkdisk to finish and run again
this is a lengthy process depending on the size of your harddrive, the percentages will fluctuate, this is normal, you can view report in the event viewer.
go to start>run> and type in eventvwr.msc, click on the applications directory, and in the right hand panel choose winlogon.
=====
http://www.pcbuyerbeware.co.uk/Windows-XP-Shutdown-Restart-Reboot-Startup-Problems.htm#shutdown
some issues here to see if the cause is a startup program or a third party service.