VBScript 中的 WScript.Shell 不适用于 Windows RT [英] WScript.Shell in VBScript not working on Windows RT

查看:29
本文介绍了VBScript 中的 WScript.Shell 不适用于 Windows RT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Surface 平板电脑上的 Windows RT 中,我运行的 VB 脚本在第一行失败:

In Windows RT on a Surface tablet, I'm running a VB script that fails on the first line which is:

Set WshShell = WScript.CreateObject("WScript.Shell")

错误信息说:

无法创建对象 WScript.Shell,错误代码为:80070005

Could not create object WScript.Shell with the error code: 80070005

这似乎是一个与访问权限有关的通用错误代码.有什么想法吗?

This seems to be a generic error code having to do with access permissions. Any ideas?

我以管理员权限运行.

推荐答案

Windows RT(也称为 Windows 8 RT、Windows 8.1 RT 和 Surface RT)使用用户模式代码完整性 (UMCI) 来限制允许的软件运行.

Windows RT (also known as Windows 8 RT, Windows 8.1 RT, and Surface RT) uses User Mode Code Integrity (UMCI) to restrict the software that is allowed to run.

在 VBScript 的情况下,UMCI 的代码完整性组件只允许创建enlightened"脚本.COM 对象.

In the case of VBScript, the Code Integrity component of UMCI only allows creation of "enlightened" COM objects.

"哪些 COM 对象受到启发?"你问.好问题.让我们在 Windows RT 设备上使用 PowerShell 来帮助我们找出答案.

"Which COM objects are enlightened?" you ask. Good question. Let's use PowerShell on our Windows RT device to help us find out.

$arrInstances = @(Get-WMIObject -ClassName 'Win32_COMSetting')
$arrCOMObjectProgIDs = @($arrInstances | Where-Object { $null -ne $_.ProgId } |
    ForEach-Object { $_.ProgId })

$ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
$result = @($arrCOMObjectProgIDs | ForEach-Object { if (New-Object -ComObject $_) { $_ } })
$result

在我打完补丁的 Surface 2 设备上,截至今天,即 2021 年 1 月 17 日,唯一具有 ProgID 的开明 COM 对象(即,唯一可从 Windows RT 上的 VBScript 调用的对象)是:

On my fully-patched Surface 2 device, as of today, 2021-Jan-17, the only enlightened COM objects with a ProgID (i.e., the only ones callable from VBScript on Windows RT) are:

  • Scripting.FileSystemObject
  • VBScript.RegExp
  • 脚本.字典

由于用户模式代码完整性 (UMCI),无法在 Windows RT 上创建其他 VBScript 对象(例如 WScript.Shell、WScript.Network、WinNTSystemInfo、Wbemscripting.SWbemLocator 等).

It is not possible to create other VBScript objects (e.g., WScript.Shell, WScript.Network, WinNTSystemInfo, Wbemscripting.SWbemLocator, etc.) on Windows RT due to User Mode Code Integrity (UMCI).

要获得上述代码的更强大版本,请查看我的脚本Get-COMObjectsProgIDsAllowedToLaunch.ps1";发布到我的 GitHub 存储库:https://github.com/franklesniak/PowerShell_Resources

For a more-robust version of the above code, check out my script "Get-COMObjectsProgIDsAllowedToLaunch.ps1" posted to my GitHub repo: https://github.com/franklesniak/PowerShell_Resources

这篇关于VBScript 中的 WScript.Shell 不适用于 Windows RT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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