It sounds like something you have running at startup is failing because it was written poorly. You need to find out what it is. First make sure the computer is virus/malwrae-free by doing some scanning.
http://www.elephantboycomputers.com/page2.html#Removing_Malware
Then if the computer is clean and the problem persists, troubleshoot your startup.
Start>Run>msconfig [enter]
This brings up the System Configuration Utility. Look on the Startup tab and find the probable culprit. Uncheck the box next to its name, Apply and OK out. You don't need to restart immediately, but the next time you do you'll get a dialog saying you've used the Utility. Just tick the box that says in effect, "don't bother me about this again".
How to Troubleshoot By Using the Msconfig Utility in Windows XP - http://support.microsoft.com/?id=310560
The free Autoruns program is very useful for managing your Startup - http://www.microsoft.com/technet/sysinternals/default.mspx
(For Vista) Start Orb>Search box>type: msconfig and when it appears in the Results box above, right-click and choose "Run as Administrator".
If you are prompted for an administrator password or for a confirmation, type the password, or click Continue. Then see what is on the Startup tab. You don't need to restart immediately, but the next time you do you'll get a dialog saying you've used the Utility. Usually in Vista this will be blocked by Windows Defender and you'll need to allow it so you can then tick the box that says in effect, "don't bother me about this again".
The free Autoruns program is very useful for managing your Startup - http://www.microsoft.com/technet/sysinternals/default.mspx
MS-MVP - Elephant Boy Computers - Don't Panic!