为什么我的 VBScript 在 Windows 10 上执行的操作与在 Windows 7 上执行的不同?

Wy doesn't my VBScript do the same thing on Windows 10 as it does on Windows 7?

我创建了一个运行一些 VBScript 的批处理文件,它在 Windows 7 中运行良好,但在 Windows 10 中运行良好。为什么它不能在两者上运行?

批处理文件做了下面列出的 6 件事。在 Windows 7 上,所有 6 件事都会发生。在 Windows 10 上,除了第 5 项外,所有内容都发生了,window 标题没有改变。

  1. 打开 Internet Explorer
  2. 将 window 置于前台
  3. 导航到网页
  4. 等待 1.5 秒以允许网页加载
  5. 将 window 标题从 "MultiSmart" 更改为 "Community MultiSmart"
  6. 退出

这是批处理文件。

<!-- :
@echo off
cscript //nologo "%~f0?.wsf" %*
exit /b
-->

<job>
  <script language="VBScript">

  Set ie = WScript.CreateObject("InternetExplorer.Application")

   'ie properties

    ie.ToolBar = 0
    ie.StatusBar = 0
    ie.Width = 816
    ie.Height = 519
    ie.Visible = 1
    ie.Resizable = 0

   'bring window to foreground
    CreateObject("WScript.Shell").AppActivate "Internet Explorer"

   'navigate to Stony Mountain Lift Station's Multismart
    ie.Navigate("http://192.168.0.11/")

   'wait for page to load into browser
    Wscript.Sleep 1500

   'change window title
    ie.document.title="Community MultiSmart"

  </script>
</job>

我会仔细检查网页是否已完全加载。

更改此行:

Wscript.Sleep 1500

While IE.ReadyState < 4
    Wscript.Sleep 250
Wend

It's unclear as to whether of:
"...Add metadata to force old browser behavior on windows 10."

worked for you or not. If not, then consider this alternative:

检查您在 IE 中的安全设置。

Warning: This answer provides suggestions that may lower your system's security settings. It is advised that you fully understand the risks involved before proceeding and be proactive with using alternative protective measures. (Or, just stop automating in IE ☺)

  • 转到IE > Internet Options > Security Tab
  • (可选) 如果您信任该网站,请将该网站添加到您的 'Trusted Sites' 区域 (这将使您的下一步更轻松)
  • 无论您决定将站点保留在哪个区域('Internet' 或 'Trusted Sites'),请取消选中复选框:启用保护模式(需要重新启动)警告:这显然会降低IE的安全性。
    • 点击应用然后确定
  • 关闭 ALL IE BROWSERS 以确保更改生效
    • 仔细检查任务管理器(Ctrl-Shift-Esc)确保没有隐藏iexplore.exe 个进程存在于 Processes 选项卡中。
  • 测试最终结果
    • 如果仍然不起作用,请确保撤消所有设置。

脚本显然对任何系统都是危险的,这就是为什么保护模式可能会严重限制您可以使用自动化执行的操作。我相信 IE 直到 Windows 8(.1)? 才默认在 IE 中启用保护模式,但我没有怀疑的来源;如果是这种情况,这就是为什么它适用于 Windows 7 而不是 Windows 10.

您仍然可以在启用保护模式的情况下做一些简单的事情,但它受到了严重限制。例如,您仍然可以导航到网页,但 IE 的许多其他属性和方法被禁用。

我正在重新发布 npocmaka 的评论,它回答了我的问题。

because it depends on the internet explorer version

版本不同。适用于 IE 11.0.966.18920 的功能不适用于 IE 11.461.16299.0.