I need to test equipment behaviour in the event that Windows hard hangs/freezes (e.g. frozen screen, no LEDs blinking, no reaction to inputs, including Ctrl+Alt+Del, etc.). In order to have enough experiments in a reasonably short time I need to initiate these hangs either programmatically or otherwise.

I am interested in Windows 10 in particular but any working way for other versions is appreciated.

Every search I've done on this topic not surprisingly brings me to discussions on how to eliminate these situations, not provoke them. So the question may seem odd enough.

Feedback: I've tried many of the recipes offered in answers and comments. First of all, I was not interested in crashes that bring BSoD (that's why I described a freeze, not a crash).

I must confess that Windows 10 64-bit showed good resistance to many of the ways. It copes with almost any CPU-load method (including fork-bomb, loops, etc.) quite well. Methods that raise immediate errors (most of NotMyFault hang methods) are handled by the OS with reboot or shutdown (which is not what I pursued). The best results were achieved by memory leak methods of NotMyFault — real freeze with no chance of reboot.

Finally, I was impressed by amount of documentation by Microsoft that talks about making Windows freeze. Looks like they know this part much better than the opposite (fighting freezes) ;-)

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – DavidPostill
    Nov 4, 2017 at 16:38
  • 3
    There is a calculation you could do using calculator, which freezes the core on the CPU until it's completed it. On a quad core machine you'd do it four times obviously. But I can't for the life of me remember the maths equation that causes it. Nov 6, 2017 at 16:15
  • 6
    @mickburkejnr It's factorial of 100000. Switch to "Scientific View" type 100000 and press "n!". This worked well on old Windows versions. Nowadays you'll get a warning that this calculation may take a long time and you can cancel it.
    – duenni
    Nov 7, 2017 at 7:08
  • 26
    Just start using it.
    – samazi
    Nov 8, 2017 at 5:57
  • 6
    Installing upgrades always worked for me. Nov 10, 2017 at 3:29

13 Answers 13


Maybe this can help: Forcing a System Crash from the Keyboard

With USB keyboards, you must enable the keyboard-initiated crash in the registry. In the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\kbdhid\Parameters, create a value named CrashOnCtrlScroll, and set it equal to a REG_DWORD value of 0x01.

You must restart the system for these settings to take effect.

After this is completed, the keyboard crash can be initiated by using the following hotkey sequence: Hold down the rightmost CTRL key, and press the SCROLL LOCK key twice.

Or you could start a fork bomb: see this SO question

There is also NotMyFault

Notmyfault is a tool that you can use to crash, hang, and cause kernel memory leaks on your Windows system. It’s useful for learning how to identify and diagnose device driver and hardware problems, and you can also use it to generate blue screen dump files on misbehaving systems.

  • 9
    Tried ForkBomb and NotMyFault. One of the leak methods seems to do what I want. Others are not useful as they bring to reboot/shutdown not freeze. Thanks a lot.
    – hypers
    Nov 3, 2017 at 9:34
  • 6
    CtrlScroll brings you a BSOD. Whether that freezes the system for debugging or just reboots it, depends on boot settings.
    – user1686
    Nov 4, 2017 at 13:51
  • 51
    Aaannnddd duenni is never allowed near my computers. Ever.
    – corsiKa
    Nov 6, 2017 at 23:14

It sounds like you're testing the reaction of an external device to an OS becoming unresponsive.

If your hardware can be connected to a virtualized Windows install, then you can pause and resume the virtual machine as many times as you like. Install the desired OS in a VirtualBox (or other desktop virtualization) environment, expose whatever hardware interface is being used (USB, Ethernet, or whatever) to the VM.

You can then pause and resume the virtual machine at will.


At least under an older Windows version (some years ago) the following worked:

I wrote a C program with an endless loop:

while(1) {}

... then I gave that program "realtime priority" in the task manager (there is also an API which can do this).

On a multi-core system I would need to do this multiple times so one loop is running on each core...

  • 39
    To heat your CPU less while doing that: put _mm_pause() from #include <immintrin.h> in the loop. That's a CPU hardware instruction, not a "sleep" system call of any sort; as far as the OS is concerned, your process is indistinguishable from SuperPI; the difference is just in how much power the CPU consumes while running the loop. Nov 2, 2017 at 12:06
  • 5
    I'm not sure if that stops the kernel mode parts of windows from working. Nov 2, 2017 at 15:49
  • 2
    @CodesInChaos: Most of the kernel threads run at normal priority. One of these per CPU and the kernel is pretty much done too.
    – Joshua
    Nov 2, 2017 at 18:47
  • Another technique involving x86 assembly (STI + HLT): stackoverflow.com/questions/3747847/…
    – meklarian
    Nov 2, 2017 at 22:29
  • 3
    @meklarian: Should be CLI; HLT. Presumably you have to do it from privileged mode, though. In principle it can still be rescued by NMI or similar. Nov 4, 2017 at 15:04

The strongest kernel hang (i.e., no mouse tracking, etc.) is when code goes into an infinite loop in kernel mode with interrupts off.

It's possible to achieve this with a device driver, and even better, you can write the driver so that it starts and stops the hang under your control (assuming the infinite loop is testing the condition you're in control of).

How to write and install this driver would be the topic of another question or three, but that's the approach I'd take.


Please check the following question on StackOverflow which is similar to yours: How to make windows freeze for short period of time

The tl;dr of it is that there's no way to (reliably) do it.

Rather than freezing or getting Windows to hang, maybe you can just interrupt the communication with your equipment.

I have no idea what your equipment is and how you connect it. If it's USB or Ethernet adapter, e.g, you could easily deactivate it in the Device Manager or unplug? If you forcefully crash or hang the system you might damage your system in various ways, so be careful with what you do.

  • 1
    I will consider physical disconnect of the equipment if I'm not satisfied with software results. Thanks.
    – hypers
    Nov 3, 2017 at 9:36

Is kernel debug mode not an option?

I've set it up in Windows 7, and the linked instructions in this answer specify XP or later, so it should work with Windows 10.

I've set it up over FireWire/1394, since it's the easiest, in my opinion. But you can also do it over the network or USB (and more).


Setup the target computer by running these commands in an elevated prompt (picking a channel n):

bcdedit /debug on
bcdedit /dbgsettings 1394 channel:n

Which is the same as going to the boot tab of msconfig, and selecting the 'Advanced' button:

enter image description here

enter image description here

Then (after rebooting the target computer), run WinDbg on the host computer using the same bitness of WinDbg of the target computer.

Then it's just a matter of pausing kernel execution whenever you want from the host computer. If you test equipment has some asynchronous operation that it is running this should be as effective as other means.

  • Interesting way. Needs a second PC though. But will try when possible.
    – hypers
    Nov 9, 2017 at 17:35

This bug (Wayback machine link) freezes Windows pretty quickly due to resource exhausting. Easy to reproduce too.

As it turns out, this is actually a bug (Wayback machine link) in how the command line (more specifically cmd.exe) parses batch files and could lead to a quick denial of service type attack; putting the following line in a batch file (with no new lines) will consume massive amounts of memory very quickly due to this bug (as an example):

^ nul<^

Long story short, when a caret is at the end of the file, the actual end of file is 'ignored' and the file handle 'reset' to 0 (essentially) so that the batch is parsed again (ad infinitum).


I don't know if this qualifies as a total freeze because the mouse cursor still moves on the screen, but Windows 7 UI becomes unresponsive if you have device I/O errors more specifically a hard drive failure. One of my hard drives was self-reporting imminent drive failure via SMART and Windows 7 would mount it but hang whenever I tried to access certain files saved on it. The UI would lock up (except for the mouse cursor movement) for up to 5 minutes until it either could read the file or dismounted the drive after the time-out. I don't know if Windows uses the system clock for the timeout, but maybe if you somehow freeze the time you can extend the timeout length? Maybe this will get you part way there, but not 100% the answer you're looking for.


Here's the source code of an application that I use in my debugging lessons. It shows how a user mode application can perform a sort of DoS attack.

You'll notice that your mouse cursor moves very seldom (once every eleven seconds on my machine). Potentially your PC will still react on the Power button if you wait long enough.

It works using an endless loop and setting the highest priority to the process (0x100 "realtime") and setting the highest priority to the threads (15 "time critical"). It will start 8 of them, which is enough for i7 computers. If you need more, adapt the loop. More of them will potentially slow down things more.

#include "stdafx.h"
#include <windows.h>
#include <string>
#include <sstream>
#include <iostream>

void WasteTime()
    int priority = 15;
    ::SetThreadPriority(::GetCurrentThread(), priority);
    while (true)

int _tmain(int argc, _TCHAR* argv[])
    ::SetPriorityClass(::GetCurrentProcess(), 0x100);
    for(int i=0; i<7; i++)
        LPDWORD threadid = 0;
        ::CreateThread(NULL, 64*1024, (LPTHREAD_START_ROUTINE)&WasteTime, NULL, 0, threadid);


    return 0;
  • Beware that this program has undefined behavior in C++, so under certain optimization settings the compiler could replace the whole thing with ExitProcess(0)
    – Ben Voigt
    Nov 10, 2017 at 19:27
  • @BenVoigt In that case (i.e. with g++) if -O0 were not enough, maybe gcc -Q -O0 --help=optimizers | grep enabled (and disabling the survived optimization by hands) may be solve the ExitProcess(0) issue?
    – Hastur
    Nov 11, 2017 at 13:42
  • @BenVoigt: could you elaborate, which part do you consider as undefined behavior? Nov 11, 2017 at 19:18
  • @BenVoigt IMHO the compiler can only optimize the return 0 statement, because that exists after the while(true). The compiler could find out that this is an unreachable statement. Nov 11, 2017 at 19:29
  • The C++ language demands that every thread eventually makes progress, defined in terms of several types of observable behavior. Because the infinite loop never makes observable progress, the compiler can deduce that it is not reached, and remove not only it, but all code above it back to the closest branch.
    – Ben Voigt
    Nov 12, 2017 at 6:18

Did you try the CPUEater utility that is bundled with Process Lasso ? Ps. I do not work for bitsum.

  • I think you mean "Have you tried", not "Did you try". :)
    – fabspro
    Nov 12, 2017 at 22:12
  • @fabspro I think "Did you try" is correct because the OP already accepted another answer so the event I am referring to ("solving the problem") is in the past, but one could probably say internet is always happening. Anyways, if you suggest an edit I will gladly delegate the task of accepting it to the review queue. Source: englishforums.com/English/HaveYouTriedOrDidYouTry/zclxb/…
    – beppe9000
    Nov 12, 2017 at 23:18
  • I guess if he had solved the problem, your enquiry could have been a comment on his answer then - something like "when you were researching your problem, was one of the things you tried _______ utility?" perhaps... just suggesting things :)
    – fabspro
    Nov 13, 2017 at 11:06
  • ... touché :)
    – beppe9000
    Nov 14, 2017 at 1:55
  • huehuehuehuehue
    – fabspro
    Nov 14, 2017 at 11:10

If you really want to hang your PC, totally causing it to just freeze, simply use up all of its RAM and force it to page memory. That will go beyond mere freezing and really just overload the thing such that you can't even use Task Manager, not even by keyboard. Even when the process is terminated, it will take a long time for the PC to recover. (It's the best!)

You could for instance create a class with a pointer to itself, and in a while loop, create a new instance of that class forever, storing each new instance in the previous instance's pointer. Maybe add some doubles or vectors to the class too, to consume memory more quickly. Then you could have a timer that exits the while loop and deconstructs everything; of course, you'll have to wait a bit for it to recover.


I would suggest simply creating a batch file with the following code:

@echo off
start cmd.exe
start explorer.exe
start calc.exe
start notepad.exe
start iexplorer.exe
start paint.exe
goto x

This is probably the easiest and safest way to do it. You can replace the process names with any windows applications.

  • 3
    This'll most likely just exhaust the RAM and cause the hard drive to be thrashed. Depending on your computer specs, it is possible that the computer will continue to work through this, especially since 4 of those programs listed are quite lightweight (iexplore.exe and maybe explorer.exe would have a bigger impact). It'll just kill off memory hogging processes automatically. Nov 6, 2017 at 10:05
  1. Go to C:\Windows\Temp\
  2. Hit Ctrl-a for Select All
  3. Hit Enter
  • 9
    You'd need many thousands of items for this to be vaguely effective! My %TEMP% folder is empty...
    – AlainD
    Nov 3, 2017 at 15:22
  • 6
    While this appears to be a legitimate attempt to answer the question, it's entirely unclear how exactly this is supposed to result in Windows locking up as requested by the OP. Please edit your question to explain why this will do what the OP wants. Nov 3, 2017 at 17:25
  • 9
    I would feel sorry for anyone who have tried this and didn't realise that they've been hit by drive-by downloads with malicious software in there. Nov 6, 2017 at 10:02
  • Besides, what about all the non-executable files? They'll just pop up a simple dialog box which after the first one is loaded, won't take any time or resources to show.
    – Synetech
    Jun 25, 2020 at 11:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.