代码之家  ›  专栏  ›  技术社区  ›  Chris Smith

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

  •  82
  • Chris Smith  · 技术社区  · 17 年前

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

    [标题:Microsoft Windows]

    X停止工作了

    一个问题导致程序停止 工作正常。窗口将关闭 如果出现以下情况,请启动程序并通知您: 解决方案是可用的。

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

    有没有办法禁用此对话框?也就是说,程序只是死机并安静地燃烧吗?

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

    四处搜索我想我已经找到了在Windows XP上禁用此功能的解决方案,该解决方案使用nuking键:

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

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

    11 回复  |  直到 10 年前
        1
  •  57
  •   Sotirios Delimanolis    17 年前

    要强制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\
    
        2
  •  46
  •   Adrian Adrian    16 年前

    请看这里:

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

    regedit

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

    将进行报告。然后你可以设置

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

    为了阻止它和史密斯女士说话。

        3
  •  36
  •   Luke Quinane George    17 年前

    我不确定这是否指的是完全相同的对话框,但这里有一种来自 Raymond Chen :

    DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
    SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
    
        4
  •  32
  •   armenzg    14 年前

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

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

        5
  •  13
  •   Gearoid Murphy    12 年前

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

    #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
  •  8
  •   Francesco Germinara    12 年前

    在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
  •  4
  •   Stefan    17 年前

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

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

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

        8
  •  4
  •   Steve Steiner    17 年前

    在测试期间,您可以使用 'debugger' like ADPlus attached 它可以通过许多有用的方式进行配置,以收集错误时的数据(小型转储),同时防止出现上面所述的模式对话框问题。

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

        9
  •  4
  •   Nick    13 年前

    我曾经 autohotkey portable

    脚本如下:

    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
    }
    

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

        10
  •  3
  •   Vicki Mollenauer    15 年前

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

    转到控制面板 服务 查看机器调试管理器的列表 右键单击它,然后单击属性 单击禁用。 单击应用并确定。

    从那以后,我再也没有看到调试器消息,我的计算机运行得很好。

        11
  •  1
  •   Sven Mawby    8 年前

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

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

    推荐文章