powershell - VBscript 无法在 Windows Insider 版本中将项目固定到任务栏
问题描述
我有一个脚本,它将一个项目固定到除 Windows Insider 构建之外的所有操作系统中的任务栏。我将它转换为 Powershell 脚本,它也适用于除 Windows Insider 构建之外的所有操作系统。当我运行它时,我没有收到任何错误消息,在事件查看器中什么也没有。MS 一直在锁定以编程方式将项目固定到“开始”菜单和任务栏的能力。看起来他们在即将发布的版本中走得更远。有没有其他人遇到过这个?这是我正在使用的代码。
Function PinItem(strFolder, strFile)
Dim ShortcutPath
Dim sKey1
Dim sKey2
Dim KeyValue
'----------------------------------------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
ShortcutPath = strFolder & "\" & strFile
sKey1 = "HKCU\Software\Classes\*\shell\{:}\\"
sKey2 = Replace(sKey1, "\\", "\ExplorerCommandHandler")
'----------------------------------------------------------------------
With WScript.CreateObject("WScript.Shell")
KeyValue = .RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" & _
"\CommandStore\shell\Windows.taskbarpin\ExplorerCommandHandler")
.RegWrite sKey2, KeyValue, "REG_SZ"
With WScript.CreateObject("Shell.Application")
With .Namespace(objFSO.GetParentFolderName(ShortcutPath))
With .ParseName(objFSO.GetFileName(ShortcutPath))
.InvokeVerb("{:}")
End With
End With
End With
.Run("Reg.exe delete """ & Replace(sKey1, "\\", "") & """ /F"), 0, True
End With
End Function
解决方案
推荐阅读
- hadoop - hive 中组合器或分区器的实现
- jupyterhub - create_system_users = True 不起作用
- laravel - 测试存储时创建的假文件
- arrays - 使用数组元素作为我想从文件中读取的变量的名称
- html - 通过 *ngFor 在 Angular 中创建盒子
- python - 关于 Protobuf PrintField() 的说明
- java - 使用 IEDriverServer 3.9.0.0 运行 selenium 时无法启动 IE 11
- javascript - 在 vanilla Javascript 中单击时将类减 1
- java - 连接到现有 Spark 集群时如何添加类或 jar?
- bash - 在 Ubuntu 上安装最新的 docker compose