Windows 10中,可以使用以下PowerShell脚本来禁用Internet Explorer的Javascript错误提示

 

Windows Registry Editor Version 5.00

; ============================================
; IE JavaScript 错误提示配置
; 说明:禁用或启用 Internet Explorer 的脚本错误提示
; ============================================

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]

; 禁用脚本调试器(防止 IE 弹出“是否调试脚本”提示)
; 通过设置此项为“yes”,可以防止 IE 弹出调试脚本窗口,
; 该窗口通常会在 JavaScript 错误发生时显示,影响用户体验。
"Disable Script Debugger"="yes"

; 禁用 IE 内核脚本调试器(防止在 IE 窗口中调试脚本)
; 设置为“yes”时,可以防止 IE 在加载网页时自动启动脚本调试器。
; 这个设置特别适用于嵌入 IE 的应用程序,避免影响正常的页面加载。
"DisableScriptDebuggerIE"="yes"

; 禁用其他类型的脚本调试器(嵌入式 IE 或其他 ActiveX 对象)
; 这个设置用于禁用在非传统 IE 环境下的脚本调试器,例如:ActiveX 控件或其他嵌入 IE 的应用。
; 将其设置为“yes”可以阻止这类调试器提示。
"DisableScriptDebuggerOther"="yes"

; 禁用每个脚本错误的通知(防止弹出错误对话框)
; 设置为“no”时,IE 会阻止弹出每次 JavaScript 错误时的提示框, 
; 使得用户在出现 JavaScript 错误时不会被打扰,从而提升体验。
"Error Dlg Displayed On Every Error"="no"

说明:

  • Disable Script Debugger:禁用 IE 提示是否调试脚本的弹窗。设置为 "yes" 时,IE 不会显示调试提示。
  • DisableScriptDebuggerIE:专门针对 IE 内核(例如,在普通 IE 窗口中)。禁止该调试器的启动。
  • DisableScriptDebuggerOther:应用于 IE 内嵌的其他控件(例如 ActiveX 控件等)。通过设置为 "yes",可以防止在这些环境下调试器弹出。
  • Error Dlg Displayed On Every Error:控制是否每次 JavaScript 错误发生时弹出提示框。设置为 "no" 时,不会弹出错误对话框。

通过这个 .reg 文件,你可以有效地避免 IE 中的脚本错误提示弹窗,对于需要隐藏这些提示的场景(如企业内网系统、自动化环境、或终端应用等)非常有帮助。

CMD 文件(ToggleIEScriptError.cmd

bat
@echo off
title IE 脚本错误提示开关
echo ================================
echo IE 脚本错误提示开关工具
echo ================================
echo 1. 禁用脚本错误提示
echo 2. 启用脚本错误提示
set /p choice=请输入选项 (1 或 2):

if "%choice%"=="1" (
    REM 禁用脚本错误提示
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Disable Script Debugger" /t REG_SZ /d "yes" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "DisableScriptDebuggerIE" /t REG_SZ /d "yes" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "DisableScriptDebuggerOther" /t REG_SZ /d "yes" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Error Dlg Displayed On Every Error" /t REG_SZ /d "no" /f
    echo 已禁用 IE 脚本错误提示.
) else if "%choice%"=="2" (
    REM 启用脚本错误提示
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Disable Script Debugger" /t REG_SZ /d "no" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "DisableScriptDebuggerIE" /t REG_SZ /d "no" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "DisableScriptDebuggerOther" /t REG_SZ /d "no" /f
    reg add "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Error Dlg Displayed On Every Error" /t REG_SZ /d "yes" /f
    echo 已启用 IE 脚本错误提示.
) else (
    echo 无效选项,程序退出.
)
pause

特点

  • 用户可以直接选择“禁用”或“启用”。
  • 不需要手动修改 .reg 文件。
  • 使用 reg add 命令修改注册表。

2️⃣ PowerShell 文件(ToggleIEScriptError.ps1

powershell
# =============================================
# IE 脚本错误提示开关工具
# 功能:启用或禁用 IE 的脚本错误提示
# 作者:自定义
# =============================================

$choice = Read-Host "请输入选项:1=禁用脚本错误提示, 2=启用脚本错误提示"

$regPath = "HKCU:\Software\Microsoft\Internet Explorer\Main"

if ($choice -eq "1") {
    # 禁用脚本错误提示
    Set-ItemProperty -Path $regPath -Name "Disable Script Debugger" -Value "yes"
    Set-ItemProperty -Path $regPath -Name "DisableScriptDebuggerIE" -Value "yes"
    Set-ItemProperty -Path $regPath -Name "DisableScriptDebuggerOther" -Value "yes"
    Set-ItemProperty -Path $regPath -Name "Error Dlg Displayed On Every Error" -Value "no"
    Write-Host "已禁用 IE 脚本错误提示。" -ForegroundColor Green
} elseif ($choice -eq "2") {
    # 启用脚本错误提示
    Set-ItemProperty -Path $regPath -Name "Disable Script Debugger" -Value "no"
    Set-ItemProperty -Path $regPath -Name "DisableScriptDebuggerIE" -Value "no"
    Set-ItemProperty -Path $regPath -Name "DisableScriptDebuggerOther" -Value "no"
    Set-ItemProperty -Path $regPath -Name "Error Dlg Displayed On Every Error" -Value "yes"
    Write-Host "已启用 IE 脚本错误提示。" -ForegroundColor Yellow
} else {
    Write-Host "无效选项,程序退出。" -ForegroundColor Red
}

特点

  • 支持彩色提示,更易读。
  • PowerShell 可以批量处理或在远程计算机上运行。
  • 功能与 .cmd 文件完全相同,但更现代化。

 

posted @ 2023-10-29 18:34  suv789  阅读(156)  评论(0)    收藏  举报