如何在Windows Vista上禁用“调试/关闭应用程序”对话框?

时间:2022-03-08 07:28:19

When an application crashes on Windows and a debugger such as Visual Studio is installed the following modal dialog appears:

当应用程序在Windows上崩溃并安装了Visual Studio等调试程序时,将显示以下模式对话框:

[Title: Microsoft Windows]

[标题:Microsoft Windows]

X has stopped working

X已停止工作

A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

一个问题导致程序停止正常工作。 Windows将关闭程序并在解决方案可用时通知您。

[Debug][Close Application]

Is there a way to disable this dialog? That is, have the program just crash and burn silently?

有没有办法禁用此对话框?也就是说,让程序崩溃并无声地刻录?

My scenario is that I would like to run several automated tests, some of which will crash due to bugs in the application under test. I don't want these dialogs stalling the automation run.

我的情况是我想运行几个自动化测试,其中一些将因测试中的应用程序中的错误而崩溃。我不希望这些对话框停止自动化运行。

Searching around I think I've located the solution for disabling this on Windows XP, which is nuking this reg key:

搜索我认为我找到了在Windows XP上禁用此功能的解决方案,这是修改此注册表项:

HKLM\Software\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger

However, that did not work on Windows Vista.

但是,这在Windows Vista上不起作用。

11 个解决方案

#1


To force Windows Error Reporting (WER) to take a crash dump and close the app, instead of prompting you to debug the program, you can set these registry entries:

要强制Windows错误报告(WER)执行故障转储并关闭应用程序,而不是提示您调试程序,您可以设置这些注册表项:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting]
"ForceQueue"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent]
"DefaultConsent"=dword:00000001

After this is set, when your apps crash, you should see *.hdmp and *.mdmp files in:

设置完成后,当您的应用程序崩溃时,您应该看到* .hdmp和* .mdmp文件:

%ALLUSERSPROFILE%\Microsoft\Windows\WER\

#2


See here:

http://msdn.microsoft.com/en-us/library/bb513638.aspx

regedit

DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\DontShowUI = "1"

DWORD HKLM或HKCU \ Software \ Microsoft \ Windows \ Windows错误报告\ DontShowUI =“1”

will make WER silently report. Then you can set

会让WER默默地报道。然后你可以设置

DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\Disabled = "1"

DWORD HKLM或HKCU \ Software \ Microsoft \ Windows \ Windows错误报告\禁用=“1”

to stop it from talking to MS.

阻止它与MS交谈。

#3


I'm not sure if this refers to exactly the same dialog but here is an alternative approach from Raymond Chen:

我不确定这是否指的是完全相同的对话框,但这是Raymond Chen的另一种方法:

DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);

#4


I had to disable this for release automation work on Windows 64-bits for Firefox and I did the following:

我不得不禁用这个用于Firefox的Windows 64位的发布自动化工作,我做了以下事情:

  • gpedit.msc
  • Computer configuration -> Administrative Templates
  • 计算机配置 - >管理模板

  • Windows Components -> Windows Error Reporting
  • Windows组件 - > Windows错误报告

  • Set "Prevent display of the user interface for critical errors" to Enabled
  • 将“防止显示关键错误的用户界面”设置为“已启用”

It is similar what was accomplished for Customer Experience reporting in: http://www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm

它类似于客户体验报告所完成的内容:http://www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm

#5


In my context, I only want to suppress the popup for my unit tests and not for the entire system. I've found that a combination of functions are needed in order to suppress these errors, such as catching unhandled exceptions, suppressing run time checks (such as the validity of the stack pointer) and the error mode flags. This is what I've used with some success:

在我的上下文中,我只想抑制单元测试的弹出窗口,而不是整个系统。我发现需要一组函数来抑制这些错误,例如捕获未处理的异常,抑制运行时检查(例如堆栈指针的有效性)和错误模式标志。这是我用过的一些成功:

#include <windows.h>
#include <rtcapi.h>
int exception_handler(LPEXCEPTION_POINTERS p)
{
    printf("Exception detected during the unit tests!\n");
    exit(1);
}
int runtime_check_handler(int errorType, const char *filename, int linenumber, const char *moduleName, const char *format, ...)
{
    printf("Error type %d at %s line %d in %s", errorType, filename, linenumber, moduleName);
    exit(1);
}

int main()
{
    DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
    SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
    SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler); 
    _RTC_SetErrorFunc(&runtime_check_handler);

    // Run your tests here

    return 0;
}

#6


In WPF application

在WPF应用程序中

[DllImport("kernel32.dll", SetLastError = true)]
static extern int SetErrorMode(int wMode);

[DllImport("kernel32.dll")]
static extern FilterDelegate SetUnhandledExceptionFilter(FilterDelegate lpTopLevelExceptionFilter);
public delegate bool FilterDelegate(Exception ex);

public static void DisableChashReport()
{
 FilterDelegate fd = delegate(Exception ex)
 {
  return true;
 };
 SetUnhandledExceptionFilter(fd);
 SetErrorMode(SetErrorMode(0) | 0x0002 );
}

#7


You have to implement an unhandled exception filter which simply quits your application, then set that filter function with SetUnhandledExceptionFilter().

您必须实现一个未处理的异常过滤器,它只是退出您的应用程序,然后使用SetUnhandledExceptionFilter()设置该过滤器函数。

If you're using the secure CRT, you also have to provide your own invalid parameter handler and set this with _set_invalid_parameter_handler().

如果您正在使用安全CRT,则还必须提供自己的无效参数处理程序,并使用_set_invalid_parameter_handler()进行设置。

This blog post has some information too: http://blog.kalmbachnet.de/?postid=75

这篇博文也有一些信息:http://blog.kalmbachnet.de/?posttid = 75

#8


During test you can run with a 'debugger' like ADPlus attached which can be configured in many useful ways to collect data (minidumps) on errors and yet prevent the modal dialog problems you state above.

在测试期间,您可以使用附加ADPlus的“调试器”运行,可以通过许多有用的方式配置它来收集错误数据(小型转储),同时防止您在上面说明的模态对话框问题。

If you want to get some useful information when your app crashes in production you can configure Microsoft Error reporting to get something similar to ADPlus data.

如果您想在应用程序在生产中崩溃时获取一些有用的信息,可以配置Microsoft错误报告以获得类似于ADPlus数据的信息。

#9


This isn't a direct answer to the question since this is a workaround and the question is about how to disable that feature, but in my case, I'm a user on a server with limited permissions and cannot disable the feature using one of the other answers. So, I needed a workaround. This will likely work for at least some others who end up on this question.

这不是问题的直接答案,因为这是一种解决方法,问题是如何禁用该功能,但在我的情况下,我是权限有限的服务器上的用户,无法使用其中一个禁用该功能其他答案。所以,我需要一个解决方法。这可能对至少一些最终解决这个问题的人有用。

I used autohotkey portable and created a macro that once a minute checks to see if the popup box exists, and if it does, clicks the button to close the program. In my case, that's sufficient, and leaves the feature on for other users. It requires that I start the script when I run the at-risk program, but it works for my needs.

我使用autohotkey portable并创建了一个宏,每分钟检查一次是否存在弹出框,如果存在,单击按钮关闭程序。在我的情况下,这就足够了,并为其他用户留下了这个功能。它要求我在运行风险程序时启动脚本,但它可以满足我的需求。

The script is as follows:

脚本如下:

sleep_duration = 60000 ; how often to check, in milliseconds.
                       ; 60000 is a full minute

Loop
{
    IfWinExist, ahk_class #32770 ; use autohotkey's window spy to confirm that
                ; ahk_class #32770 is it for you. This seemed to be consistent
                ; across all errors like this on Windows Server 2008
    {
        ControlClick, Button2, ahk_class #32770 ; sends the click.
                ; Button2 is the control name and then the following
                ; is that window name again
    }
    Sleep, sleep_duration ; wait for the time set above
}

edit: A quick flag. When other things are up, this seems to attempt to activate controls in the foreground window - it's supposed to send it to the program in the background. If I find a fix, I'll edit this answer to reflect it, but for now, be cautious about using this and trying to do other work on a machine at the same time.

编辑:快速标记。当其他事情发生时,这似乎试图在前台窗口中激活控件 - 它应该在后台将它发送到程序。如果我找到了修复程序,我将编辑此答案以反映它,但是现在,请谨慎使用它并尝试同时在计算机上执行其他工作。

#10


After trying everything else on the internet to get rid of just in time debugger, I found a simple way that actually worked and I hope will help someone else.

在尝试了互联网上的其他所有内容以摆脱及时调试器后,我发现了一种实际工作的简单方法,我希望能帮助其他人。

Go to Control Panel Go to Administrative Tools Go to Services Look down the list for Machine Debug Manager Right Click on it and click on Properties Under the General Tab, look for Start Up Type Click on Disable. Click on Apply and OK.

转到控制面板转到管理工具转到服务查看机器调试管理器列表右键单击它并单击属性在常规选项卡下,查找启动类型单击禁用。单击“应用”和“确定”。

I haven't seen the debugger message since, and my computer is running perfectly.

从那以后我没有看到调试器消息,我的电脑运行正常。

#11


Instead of changing values in the registry you can completly disable the error reporting on Windows Server 2008 R2, Windows Server 2012 and Windows 8 with: serverWerOptin /disable

您可以使用以下命令完全禁用Windows Server 2008 R2,Windows Server 2012和Windows 8上的错误报告,而不是更改注册表中的值:serverWerOptin / disable

https://technet.microsoft.com/en-us/library/hh875648(v=ws.11).aspx

#1


To force Windows Error Reporting (WER) to take a crash dump and close the app, instead of prompting you to debug the program, you can set these registry entries:

要强制Windows错误报告(WER)执行故障转储并关闭应用程序,而不是提示您调试程序,您可以设置这些注册表项:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting]
"ForceQueue"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent]
"DefaultConsent"=dword:00000001

After this is set, when your apps crash, you should see *.hdmp and *.mdmp files in:

设置完成后,当您的应用程序崩溃时,您应该看到* .hdmp和* .mdmp文件:

%ALLUSERSPROFILE%\Microsoft\Windows\WER\

#2


See here:

http://msdn.microsoft.com/en-us/library/bb513638.aspx

regedit

DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\DontShowUI = "1"

DWORD HKLM或HKCU \ Software \ Microsoft \ Windows \ Windows错误报告\ DontShowUI =“1”

will make WER silently report. Then you can set

会让WER默默地报道。然后你可以设置

DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\Disabled = "1"

DWORD HKLM或HKCU \ Software \ Microsoft \ Windows \ Windows错误报告\禁用=“1”

to stop it from talking to MS.

阻止它与MS交谈。

#3


I'm not sure if this refers to exactly the same dialog but here is an alternative approach from Raymond Chen:

我不确定这是否指的是完全相同的对话框,但这是Raymond Chen的另一种方法:

DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);

#4


I had to disable this for release automation work on Windows 64-bits for Firefox and I did the following:

我不得不禁用这个用于Firefox的Windows 64位的发布自动化工作,我做了以下事情:

  • gpedit.msc
  • Computer configuration -> Administrative Templates
  • 计算机配置 - >管理模板

  • Windows Components -> Windows Error Reporting
  • Windows组件 - > Windows错误报告

  • Set "Prevent display of the user interface for critical errors" to Enabled
  • 将“防止显示关键错误的用户界面”设置为“已启用”

It is similar what was accomplished for Customer Experience reporting in: http://www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm

它类似于客户体验报告所完成的内容:http://www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm

#5


In my context, I only want to suppress the popup for my unit tests and not for the entire system. I've found that a combination of functions are needed in order to suppress these errors, such as catching unhandled exceptions, suppressing run time checks (such as the validity of the stack pointer) and the error mode flags. This is what I've used with some success:

在我的上下文中,我只想抑制单元测试的弹出窗口,而不是整个系统。我发现需要一组函数来抑制这些错误,例如捕获未处理的异常,抑制运行时检查(例如堆栈指针的有效性)和错误模式标志。这是我用过的一些成功:

#include <windows.h>
#include <rtcapi.h>
int exception_handler(LPEXCEPTION_POINTERS p)
{
    printf("Exception detected during the unit tests!\n");
    exit(1);
}
int runtime_check_handler(int errorType, const char *filename, int linenumber, const char *moduleName, const char *format, ...)
{
    printf("Error type %d at %s line %d in %s", errorType, filename, linenumber, moduleName);
    exit(1);
}

int main()
{
    DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
    SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
    SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler); 
    _RTC_SetErrorFunc(&runtime_check_handler);

    // Run your tests here

    return 0;
}

#6


In WPF application

在WPF应用程序中

[DllImport("kernel32.dll", SetLastError = true)]
static extern int SetErrorMode(int wMode);

[DllImport("kernel32.dll")]
static extern FilterDelegate SetUnhandledExceptionFilter(FilterDelegate lpTopLevelExceptionFilter);
public delegate bool FilterDelegate(Exception ex);

public static void DisableChashReport()
{
 FilterDelegate fd = delegate(Exception ex)
 {
  return true;
 };
 SetUnhandledExceptionFilter(fd);
 SetErrorMode(SetErrorMode(0) | 0x0002 );
}

#7


You have to implement an unhandled exception filter which simply quits your application, then set that filter function with SetUnhandledExceptionFilter().

您必须实现一个未处理的异常过滤器,它只是退出您的应用程序,然后使用SetUnhandledExceptionFilter()设置该过滤器函数。

If you're using the secure CRT, you also have to provide your own invalid parameter handler and set this with _set_invalid_parameter_handler().

如果您正在使用安全CRT,则还必须提供自己的无效参数处理程序,并使用_set_invalid_parameter_handler()进行设置。

This blog post has some information too: http://blog.kalmbachnet.de/?postid=75

这篇博文也有一些信息:http://blog.kalmbachnet.de/?posttid = 75

#8


During test you can run with a 'debugger' like ADPlus attached which can be configured in many useful ways to collect data (minidumps) on errors and yet prevent the modal dialog problems you state above.

在测试期间,您可以使用附加ADPlus的“调试器”运行,可以通过许多有用的方式配置它来收集错误数据(小型转储),同时防止您在上面说明的模态对话框问题。

If you want to get some useful information when your app crashes in production you can configure Microsoft Error reporting to get something similar to ADPlus data.

如果您想在应用程序在生产中崩溃时获取一些有用的信息,可以配置Microsoft错误报告以获得类似于ADPlus数据的信息。

#9


This isn't a direct answer to the question since this is a workaround and the question is about how to disable that feature, but in my case, I'm a user on a server with limited permissions and cannot disable the feature using one of the other answers. So, I needed a workaround. This will likely work for at least some others who end up on this question.

这不是问题的直接答案,因为这是一种解决方法,问题是如何禁用该功能,但在我的情况下,我是权限有限的服务器上的用户,无法使用其中一个禁用该功能其他答案。所以,我需要一个解决方法。这可能对至少一些最终解决这个问题的人有用。

I used autohotkey portable and created a macro that once a minute checks to see if the popup box exists, and if it does, clicks the button to close the program. In my case, that's sufficient, and leaves the feature on for other users. It requires that I start the script when I run the at-risk program, but it works for my needs.

我使用autohotkey portable并创建了一个宏,每分钟检查一次是否存在弹出框,如果存在,单击按钮关闭程序。在我的情况下,这就足够了,并为其他用户留下了这个功能。它要求我在运行风险程序时启动脚本,但它可以满足我的需求。

The script is as follows:

脚本如下:

sleep_duration = 60000 ; how often to check, in milliseconds.
                       ; 60000 is a full minute

Loop
{
    IfWinExist, ahk_class #32770 ; use autohotkey's window spy to confirm that
                ; ahk_class #32770 is it for you. This seemed to be consistent
                ; across all errors like this on Windows Server 2008
    {
        ControlClick, Button2, ahk_class #32770 ; sends the click.
                ; Button2 is the control name and then the following
                ; is that window name again
    }
    Sleep, sleep_duration ; wait for the time set above
}

edit: A quick flag. When other things are up, this seems to attempt to activate controls in the foreground window - it's supposed to send it to the program in the background. If I find a fix, I'll edit this answer to reflect it, but for now, be cautious about using this and trying to do other work on a machine at the same time.

编辑:快速标记。当其他事情发生时,这似乎试图在前台窗口中激活控件 - 它应该在后台将它发送到程序。如果我找到了修复程序,我将编辑此答案以反映它,但是现在,请谨慎使用它并尝试同时在计算机上执行其他工作。

#10


After trying everything else on the internet to get rid of just in time debugger, I found a simple way that actually worked and I hope will help someone else.

在尝试了互联网上的其他所有内容以摆脱及时调试器后,我发现了一种实际工作的简单方法,我希望能帮助其他人。

Go to Control Panel Go to Administrative Tools Go to Services Look down the list for Machine Debug Manager Right Click on it and click on Properties Under the General Tab, look for Start Up Type Click on Disable. Click on Apply and OK.

转到控制面板转到管理工具转到服务查看机器调试管理器列表右键单击它并单击属性在常规选项卡下,查找启动类型单击禁用。单击“应用”和“确定”。

I haven't seen the debugger message since, and my computer is running perfectly.

从那以后我没有看到调试器消息,我的电脑运行正常。

#11


Instead of changing values in the registry you can completly disable the error reporting on Windows Server 2008 R2, Windows Server 2012 and Windows 8 with: serverWerOptin /disable

您可以使用以下命令完全禁用Windows Server 2008 R2,Windows Server 2012和Windows 8上的错误报告,而不是更改注册表中的值:serverWerOptin / disable

https://technet.microsoft.com/en-us/library/hh875648(v=ws.11).aspx