如何通过脚本以编程方式确定IE的安装版本 [英] How to programmatically determine the installed version of IE from a script

查看:86
本文介绍了如何通过脚本以编程方式确定IE的安装版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个基于硒网格的自动化测试集群.

We have an automated testing cluster based on selenium-grid.

为了管理集群,我构建了一组Rake(Ruby)任务,这些任务可以启动,重新启动,ping和停止节点.我正在多种浏览器(包括IE6,IE7和IE8)上测试我们的应用程序.这意味着群集中的每个节点都必须知道安装了IE的哪个版本,以便可以声明正确的硒网格配置文件名称(例如:"IE6 on Windows XP""IE8 on Windows Vista"),以便可以编写某些测试.针对那些浏览器.

To manage the cluster, I have built a collection of Rake (Ruby) tasks which can start, restart, ping, and stop nodes. I'm testing our application across a number of browsers including IE6, IE7, and IE8. This means each node in the cluster has to be aware of which version of IE is installed so that it can claim the correct selenium-grid profile name (eg: "IE6 on Windows XP" vs. "IE8 on Windows Vista"), so that certain tests can be written against those browsers.

我的问题:

我想减少此处的配置工作.如何以编程方式确定当前系统上正在运行哪个版本的IE?我尝试了以下技术:

I'd like to cut down on the configuration work here. How do I programmatically determine which version of IE is running on the current system? I have tried the following technique:

wmic product where "Vendor like '%Microsoft%'" get Name, Version

但这只会返回Windows Installer安装的程序版本,因此IE不会显示在此列表中.

But this only returns versions of programs that were installed with the Windows Installer, so IE doesn't show up in this list.

理想情况下,我希望能够从Rake脚本或至少可以从Rake脚本调用的内容中确定这一点.

Ideally I'd like to be able to determine this from inside of a Rake script, or at least something that's callable from a Rake script.

推荐答案

您可以使用WMI,我知道这不是rake脚本,但是您可以运行该脚本(或创建.NET应用程序)并将结果输入到您的应用程序.

You can use WMI, I know it's not a rake script, but you could run the script (or create a .NET application) and feed the results into your application.

这有点像骇客,但至少能奏效.这是来自technet的一些代码.

It's kind of a hack, but at least it will work. Here's some code from technet.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
    "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Summary")

For Each strIESetting in colIESettings
    Wscript.Echo strIESetting.Version
Next

完整一旦有了这些信息,就可以使用命令行将该信息传递给rake脚本.

Once you have this information, you can pass the information to your rake script using the command line.

rake YourScript[<argument from vbscript>]

编辑:您可以将此代码复制/粘贴到文件中,命名为any.vbs,然后使用 cscript 命令执行脚本.

You can copy/paste this code into a file, name it whatever.vbs, and use the cscript command to execute the script.

cscript//Nologo ie_version.vbs

cscript //Nologo ie_version.vbs

这篇关于如何通过脚本以编程方式确定IE的安装版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆