What do you mean "right before the OS starts up"? Do you mean immediatly after the POST screen? Or do you actually get to the windows loading screen? If it's the first case, then I would check BIOs for any settings on error recovery (ie what the comp should do after an error). You might be able to cause the computer to do nothing upon post errors (ie just sit there), then gradually reset the things to "reboot on error" and see what is causeing the problem. If you don't want to do that, unplug all extraneous periphials (just leave RAM, HD and video card) and see if it boots that way, then plug them back in one by one to see what is the problem. Just some thoughts I had and the general suggestions for boot up issues, I have never actually tried any myself.
If it gets to the windows loading screen, try the above tip with removing hardware, and if it still doesn't work, reboot it and keep hitting F8, which should bring up some boot options for windows, select safe mode and see if it boots that way. If it dows, while in safe mode, open msconfig and disable all startup items, and see if it works normally. Then renable them to see what is causing the problem.