【问题标题】:Internet Explorer 11 detection from Batch File从批处理文件检测 Internet Explorer 11
【发布时间】:2014-02-04 10:22:22
【问题描述】:

我想问你是否有办法在批处理文件中执行以下操作:

1) 从注册表中读取 Internet Explorer 版本。

2) 如果 Internet Explorer 版本低于 11,则弹出消息“您正在运行不同版本的 Internet Explorer。应用程序将关闭”,然后按一下按钮退出应用程序;

3) 如果 Internet Explorer 为 11 或更高版本,则弹出消息“您正在运行 Internet Explorer 11 或更高版本”;

然后将从 c:\myfolder 导入一个 Reg 文件,然后批处理文件应显示类似“操作完成。按一个按钮关闭窗口”。

我知道 IE 11 在以下路径中放置了一个名为“svcVersion”的配置单元

"HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer

我想知道你们中的任何人是否可以帮助我如何“指示”批处理文件从注册表中读取以查找该参数,然后按照上述方式进行操作。 非常感谢您的帮助。 美莲娜

【问题讨论】:

    标签: internet-explorer batch-file


    【解决方案1】:

    应该这样做:

    @echo off
    setlocal
    cd /d %~dp0
    set regquery=reg query "HKLM\Software\Microsoft\Internet Explorer" /v svcVersion
    for /f "tokens=3" %%a in ('%regquery%') do (
      for /f "tokens=1 delims=." %%b in ("%%a") do (
        if %%b LSS 11 echo you are running a different version of Internet explorer. Application will close & goto :eof
        if %%b GEQ 11 (
           echo You are running Internet explorer 11 or higher.
           echo REGEDIT /S C:\myfolder\myfile.reg
           echo Operation finished. Press any key to close window.
           pause>nul
        )
      )
    )
    

    在将 myfile.reg 更改为正确名称后,删除 regedit 之前的回显。

    【讨论】:

    • 嗨,马特,感谢您的帮助。我不知道在不运行 IE11 的系统中,“HKLM\Software\Microsoft\Internet Explorer”中的“svcVersion”字符串不存在,因此该批处理应查询注册表以在该路径中查找“svcVersion”(对不起,我的错误)。 1)如果它发现它应该显示“你正在运行 Internet Explorer 11”,应用 myregfile.reg 并在按下按钮后关闭,2)如果它没有找到,只显示“你没有运行 Internet Explorer 11”并关闭按下按钮后
    • 我尝试使用 reg 查询 "HKLM\Software\Microsoft\Internet Explorer" /v svcVersion IF %errorlevel%==0 GOTO IE11 IF %errorlevel%==1 GOTO NOTIE11 :IE11 echo "This是 IE 11" REGEDIT /S C:\myfolder\myfile.reg echo "操作完成。按任意键关闭窗口" pause>nul exit :NOTIE11 echo "你没有运行 IE11。按任意键关闭窗口" pause>nul出口。但是当我运行 Reg Query 时,我会在屏幕 HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer svcVersion REG_SZ 11.0.9600.16476 上看到我想隐藏的输出。有没有办法做到这一点?
    • 我有 IE10,我的注册表中有 svcVersion。要不显示输出,请将其发送到 nul。 reg query "HKLM\Software\Microsoft\Internet Explorer" /v svcVersion >nul
    猜你喜欢
    • 2019-11-20
    • 1970-01-01
    • 2015-05-29
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    相关资源
    最近更新 更多