简体   繁体   English

从批处理文件检测Internet Explorer 11

[英]Internet Explorer 11 detection from Batch File

I would like to ask you if there is a way in a batch file to do the following: 我想问你一个批处理文件中是否可以执行以下操作:

1) Read Internet explorer version from the registry. 1)从注册表中读取Internet Explorer版本。

2) If internet explorer is less than version 11 pop up a message "you are running a different version of Internet explorer. Application will close" and then exit application after pressing a button; 2)如果Internet Explorer低于11版,则会弹出一条消息“您正在运行其他版本的Internet Explorer。应用程序将关闭”,然后在按下按钮后退出应用程序;

3) If internet explorer is 11 or higher then pop up message "You are running Internet explorer 11 or higher"; 3)如果Internet Explorer为11或更高,则弹出消息“您正在运行Internet Explorer 11或更高”;

A Reg file will then be imported from c:\\myfolder and then batch file should show up something like "Operation finished.Press one button to close window". 然后将从c:\\ myfolder导入Reg文件,然后批处理文件应显示类似“操作完成。按一个按钮以关闭窗口”之类的内容。

I know IE 11 places a hive called "svcVersion" in the following path 我知道IE 11在以下路径中放置了一个名为“ svcVersion”的配置单元

"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer “ HKEY_LOCAL_MACHINE \\ Software \\ Microsoft \\ Internet Explorer

I wonder if any of you might be help me how to "instruct" the batch file to read from the registry looking for that parameter and then do as above. 我想知道是否有人可以帮助我如何“指示”批处理文件以从注册表中读取以查找该参数,然后执行上述操作。 Thank you very much indeed for your help. 确实非常感谢您的帮助。 Meleena Meleena

This should do it: 应该这样做:

@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
    )
  )
)

Remove the echo before regedit after you change myfile.reg the the correct name. 更改myfile.reg为正确的名称后,请在regedit之前删除回显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM