【问题标题】:open Internet Explorer in Java without specifying the path在 Java 中打开 Internet Explorer 而不指定路径
【发布时间】:2015-05-21 08:16:21
【问题描述】:

我想在不知道确切路径的情况下通过新会话动态打开 Internet Explorer。我尝试从 Java 中打开 Internet Explorer,使用:

Runtime.getRuntime().exec("iexplore.exe -noframemerging http://google.com/");

但由于iexplore.exe 未在系统变量中定义,因此无法找到位置。

请给我建议一些前进的方法。

【问题讨论】:

标签: java internet-explorer runtime.exec


【解决方案1】:

以下操作会将 google 加载到您在 Windows 上的默认浏览器中...

Runtime.getRuntime().exec("cmd /c start http://google.com/");

【讨论】:

  • 非常感谢。你节省了我的时间。它工作得非常好..只需一个查询,“/c”有什么用?
  • 欢迎您! /c 参数告诉 cmd 运行后面的命令 - 在本例中为 start google.com。如果你输入 cmd /?在命令提示符下,您会在 cmd 上看到大量信息
【解决方案2】:
Process browser = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe \"http://www.google.com\"");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-20
    • 1970-01-01
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    相关资源
    最近更新 更多