59

I'm trying to debug a Visual Studio C# Windows application that immediately takes over the desktop and disables mouse control. When it freezes, I need to be able to stop it somehow. I can press the windows key or ctrl-alt-delete and access the taskbar, but when I move the mouse onto the main part of my screen it's always an hourglass icon and I can't interact. So when I right-click to close the application on the taskbar and a dialogue pops up asking if I want to stop debugging, there's no way for me to click it. I also can't click on anything in task manager.

I looked into how to end tasks from command prompt, but the directions don't make sense. schtasks /end requires a task name argument that seems to take a path, but I have no way of knowing what the path is that I'm supposed to input. tasklist returns file names and ID numbers, but neither of those work for schtasks.

Does anyone have any suggestions?

12
  • 3
    ALT+F4 will close any program on Windows
    – Ramhound
    Commented Mar 18, 2017 at 16:35
  • 59
    @Ramhound Alt+F4 will send a window-close message to the application. If it's unwilling to handle it (e.g. by dropping the event or doing something else) this won't work.
    – nanofarad
    Commented Mar 18, 2017 at 16:40
  • 3
    @Ramhound It won't close non-GUI programs or programs that choose to ignore the close event. Commented Mar 18, 2017 at 16:42
  • 18
    pull the plug, afaik this worked for all versions of windows. Commented Mar 19, 2017 at 9:11
  • 10
    Using Ctrl+Alt+Del, Ctrl+Shift+Esc, Win+R and so one don't necessarily require you to use your mouse. Almost all of Windows's functionalities can be used using the keyboard only. For this, you can use the arrow keys, the tab key, or Alt key navigation.
    – BlueCacti
    Commented Mar 19, 2017 at 22:44

11 Answers 11

99

You can use the command prompt to terminate processes:

  1. Open the Run box using Windows+R.
  2. Type cmd in the Run box and click Enter.
  3. Use the command tasklist to list all processes.
  4. Use the command taskkill /F /IM "executable name.exe" /T to terminate the process.
20
  • 17
    Or just type cmd /C taskkill /f /im "<whatever>" /t in the "Run" window. Commented Mar 18, 2017 at 16:41
  • 10
    @MJ9 You can, you just need to be a very quick reader :P Commented Mar 18, 2017 at 19:44
  • 16
    @IsmaelMiguel You don't even need the cmd /C part; taskkill isn't a shell built-in.
    – wizzwizz4
    Commented Mar 18, 2017 at 21:45
  • 4
    @wizzwizz4 OMG! You're totally right! You can straight type taskkill there! I forgot that it is an executable placed inside system32 (if I remember correctly). This means, a huge reduction of steps. And once you've done this once, all you have to do is Win + R and then hit Enter. Commented Mar 18, 2017 at 22:47
  • 3
    @MJ9 "can't do tasklist in Run" cmd /K tasklist Commented Mar 19, 2017 at 20:28
92

Try the following:

  1. Open the Task Manager by pressing Ctrl+Shift+Esc
  2. Navigate using the arrow keys ( and ) to highlight the problematic process
  3. Press the Delete key to kill the process
  4. If necessary, acknowledge the subsequent prompt by selecting the appropriate choice with the arrow keys ( or ) and press Enter
13
  • 2
    You will need Del -> Enter; there's a prompt.
    – wizzwizz4
    Commented Mar 18, 2017 at 17:30
  • @wizzwizz4 thanks for the feedback! That is a very good point. There isn't an additional prompt in some cases, but a program that is frozen will typically have one. I have added an additional step to the answer.
    – Run5k
    Commented Mar 18, 2017 at 20:26
  • In my version of Task Manager (Win 10 Home), the Delete key to kill a process pops up with the "are you sure you want to do this? this could pwn your system" message. I'd be interested to know which systems this doesn't always appear for.
    – wizzwizz4
    Commented Mar 18, 2017 at 21:44
  • 1
    @wizzwizz4 I think it also depends upon your target. On my Windows 10 Pro x64 machine I have tried it on Notepad, Paint, and the Settings app. Each of them closes without any additional prompts.
    – Run5k
    Commented Mar 18, 2017 at 22:06
  • This works! Thank you. I have a few choices for the correct answer here. I hope you don't mind me picking one with fewer votes. The arrow keys wouldn't respond the first time I tried your solution, so I'm going to say the other one is more consistent, and it has some good info about using the command prompt. Commented Mar 19, 2017 at 1:40
12

A slight modification of the Taskkill answer: You can use wildcard if you don't remember/know the exact full name of the process, like so:

taskkill /f /im badproce*

It will kill all executables starting with that name, so make sure you don't just type something like s* because that could obviously kill critical processes like svchost.

Also, the /T flag is for killing the tree of processes, which is the target process and all the child processes it spawned. It may not be necessary most of the time.

3
  • 1
    If I recall, it ignores important processes at least on Windows 10. I didn't know that it accepted a wildcard. Thanks.
    – Codingale
    Commented Mar 20, 2017 at 13:00
  • 1
    This reminds me of a very dumb thing I did when I started working: I had to write a script that killed some processes of which I had the PID, on a Unix machine. I don't remember the details, but I was parsing the output of ps -ef with a regex containing the PID, and if it matched I had to send a kill -9. Now, for some reason, my regex didn't match, so I tried to make it "broader". It didn't work. Then broader, then broader... Frustrated, I decided to try something that worked for sure, and I used /2/ as regex for the PID. Yay, it worked! kill -9 to all the PIDs containing 2... X_X Commented Mar 22, 2017 at 13:03
  • I still remember my surprise when I hit enter and the shell I was using was closed. Then I realized what had happened. To top it off, kill doesn't work on processes of other users, but unfortunately we were like 20 people sharing the same account on that machine... It wasn't a funny day. The moral of the story is: if you use wildcards, pay a lot of attention! Commented Mar 22, 2017 at 13:04
9

Microsoft/Sysinternals' pskill tool can be used to kill a process via a command prompt, and it allows you to kill processes by process ID numbers or by process name. It also can be used to kill processes remotely: if the misbehaving program also managed to prevent you from using the keyboard, you could install pskill on another machine on your local network to kill the offending process.

7

You can kill the process from another device.

Alternative A: In "Settings -> For Developers -> Enable Device Portal". If you enable it, you get a web portal you can access from any other web-browsable device. With it you can list the running processes, and according to the documentation:

On some platforms (Desktop, IoT, and HoloLens) you can terminate processes.

Unfortunately, it currently doesn't seem to work on my computer, clicking on the "X" buttons besides each process does nothing.

Alternative B: If you have a Windows Mobile or another windows device, you can install the VoiceWake app from the Store, and its server component on your computer. Then you can use the app to kill the process remotely.

And there are certainly other applications out there that does the same.

1
  • This is a very clever idea! I'd prefer not to take the time to test it though, since I already have some working solutions. I think this is a good fallback in a situation where the keyboard doesn't respond. Commented Mar 19, 2017 at 1:41
5

I am not sure where the trouble with Ctrl+Alt+Del is occurring, but I am able to use it along with the arrow keys to open the Task Manager. From there, you can follow the answer provided by @Run5K to end processes:

  1. Press Ctrl+Alt+Del

  2. Use the arrow keys to select Task Manager, and press Enter to open (I had to press Enter twice open Task Manager)

  3. When the permissions dialog box appears, use the arrow keys and Enter to select Yes to allow Task Manager permission to make changes

    From here, you can follow @Run5k's answer from list item (2):

  4. Use the arrow keys (Up and Down) to select the process desired to end. You can also use the Left and Right arrows to open/close collapsed/expanded items and end sub-processes

  5. Use Delete to end the process

  6. Use the arrow keys and Enter to manage any dialog boxes that may appear

2

I use Ctrl + Shift + Esc Then I get the Task manager window. With Alt-Tab I try to switch to task manager, and then I navigate trough open apps with arrow keys. When you select your application, just press Delete button.

1

If you are debugging an application, you can press Shift+F5 in visual studio to close the running instance.

Of course if you are in run mode you should rely on the other answers.

2
  • 1
    What is the MAJ key? Do you mean Shift?
    – Mixxiphoid
    Commented Mar 20, 2017 at 10:48
  • 1
    Oops! Correct! Editing my answer
    – Goufalite
    Commented Mar 20, 2017 at 12:11
1

Many years ago, when mice didn't exist I used to close an application by pressing F10 to get into the menu bar, arrow down to open the menu, arrow left to get into the system menu and then arrow up to get to "Close" and press enter. It still works with simple applications like Notepad, depending on the kind of menu they have. (I don't remember why I favoured that over Alt-F4 at that time, maybe it was more impressing for people watching you doing it ;)

3
  • Does your method work in Windows 10? OP asks specifically about Windows 10 (see the Windows 10 tag). Update your answer if it works in Windows 10 or remove it. Commented Mar 21, 2017 at 3:51
  • 1
    @alljamin : sure. This is CUA (Common User Application) equivalent of pressing Alt to get a menu. And CUA is widely supported by many Windows applications. (other examples: Shift-Del for cut, Shift-Ins for insert.) Widely supported, including Windows 10.
    – TOOGAM
    Commented Mar 21, 2017 at 5:48
  • Alt+Space,C is a similar approach.
    – RJFalconer
    Commented Mar 21, 2017 at 16:01
-1

Open Run Box and type:

cmd /c tskill process_name 

tskill is a program file in the dir C:\windows\system32

1
  • 2
    no need for cmd /c
    – phuclv
    Commented Mar 20, 2017 at 9:48
-3

ALT-F4 is the quickest way.

Another option without using mouse is CTRL+ALT+DEL, Task manager and kill required application

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .