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

发布于 2024-07-10 03:10:54 字数 572 浏览 10 评论 0原文

当应用程序在 Windows 上崩溃并且安装了 Visual Studio 等调试器时,会出现以下模式对话框:

[标题:Microsoft Windows]

X 已停止工作

出现问题导致程序停止 工作正常。 窗户将关闭 该计划并通知您,如果 解决方案可用。

[调试][关闭应用程序]

有没有办法禁用此对话框? 也就是说,程序是否会悄无声息地崩溃并烧毁?

我的情况是,我想运行几个自动化测试,其中一些测试会由于被测应用程序中的错误而崩溃。 我不希望这些对话框阻碍自动化运行。

四处搜索,我想我已经找到了在 Windows XP 上禁用此功能的解决方案,该解决方案会删除此注册表项:

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

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

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

[Title: Microsoft Windows]

X has stopped working

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

[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:

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

However, that did not work on Windows Vista.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

机场等船 2024-07-17 03:10:54

要强制 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

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

%ALLUSERSPROFILE%\Microsoft\Windows\WER\

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 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:

%ALLUSERSPROFILE%\Microsoft\Windows\WER\
清音悠歌 2024-07-17 03:10:54

请参阅此处:

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

regedit

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

将使 WER 默默报告。 然后你可以设置

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

来阻止它与 MS 通信。

See here:

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

regedit

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

will make WER silently report. Then you can set

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

to stop it from talking to MS.

猫七 2024-07-17 03:10:54

我不确定这是否指的是完全相同的对话框,但这是 陈雷蒙

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

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

DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
何止钟意 2024-07-17 03:10:54

我必须禁用此功能才能在 Firefox 的 Windows 64 位上进行发布自动化工作,并且执行了以下操作:

  • gpedit.msc
  • 计算机配置 -> 管理模板
  • Windows 组件 -> Windows 错误报告
  • 将“防止显示严重错误的用户界面”设置为“已启用”,

这与客户体验报告的完成情况类似:
http:// /www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm

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

  • gpedit.msc
  • Computer configuration -> Administrative Templates
  • Windows Components -> Windows Error Reporting
  • 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

蓝咒 2024-07-17 03:10:54

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

#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;
}

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;
}
夜声 2024-07-17 03:10:54

在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 );
}

In WPF application

[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 );
}
西瓜 2024-07-17 03:10:54

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

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

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

You have to implement an unhandled exception filter which simply quits your application, then set that filter function with 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().

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

夜吻♂芭芘 2024-07-17 03:10:54

在测试过程中,您可以使用附加的“调试器”(如 ADPlus)运行可以通过许多有用的方式进行配置,以收集错误数据(小型转储),并防止您上面提到的模式对话框问题。

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

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.

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.

浴红衣 2024-07-17 03:10:54

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

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

脚本如下:

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
}

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

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.

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.

听你说爱我 2024-07-17 03:10:54

在尝试了互联网上的其他所有方法来摆脱即时调试器之后,我找到了一种实际有效的简单方法,我希望对其他人有所帮助。

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

从那以后我再也没有看到调试器消息,并且我的计算机运行完美。

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.

挽心 2024-07-17 03:10:54

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文