参考@Humberto Freitas的回答,我对其进行了修改以达到我的目的,您可以尝试使用此Vbscript在Windows 10中固定程序到任务栏。
Vbscript: TaskBarPin.vbs
Option Explicit
REM Question Asked here ==>
REM https://dev59.com/ylwZ5IYBdhLWcg3wM9_Z#34182076
Dim Title,objFSO,ws,objFile,sKey1,sKey2,KeyValue
Title = "Pin a program to taskbar using Vbscript in Windows 10"
'----------------------------------------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Ws = CreateObject("WScript.Shell")
objFile = DeQuote(InputBox("Type the whole path of the program to be pinned or unpinned !",Title,_
"%ProgramFiles%\windows nt\accessories\wordpad.exe"))
REM Examples
REM "%ProgramFiles%\Mozilla Firefox\firefox.exe"
REM "%ProgramFiles%\Google\Chrome\Application\chrome.exe"
REM "%ProgramFiles%\windows nt\accessories\wordpad.exe"
REM "%Windir%\Notepad.exe"
ObjFile = ws.ExpandEnvironmentStrings(ObjFile)
If ObjFile = "" Then Wscript.Quit()
sKey1 = "HKCU\Software\Classes\*\shell\{:}\\"
sKey2 = Replace(sKey1, "\\", "\ExplorerCommandHandler")
'----------------------------------------------------------------------
With CreateObject("WScript.Shell")
KeyValue = .RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" & _
"\CommandStore\shell\Windows.taskbarpin\ExplorerCommandHandler")
.RegWrite sKey2, KeyValue, "REG_SZ"
With CreateObject("Shell.Application")
With .Namespace(objFSO.GetParentFolderName(objFile))
With .ParseName(objFSO.GetFileName(objFile))
.InvokeVerb("{:}")
End With
End With
End With
.Run("Reg.exe delete """ & Replace(sKey1, "\\", "") & """ /F"), 0, True
End With
'----------------------------------------------------------------------
Function DeQuote(S)
If Left(S,1) = """" And Right(S, 1) = """" Then
DeQuote = Trim(Mid(S, 2, Len(S) - 2))
Else
DeQuote = Trim(S)
End If
End Function
'----------------------------------------------------------------------
编辑:2020年12月24日
参考:
Windows 10中的Microsoft Edge位于哪里?我该如何启动它?
Microsoft Edge应该在任务栏中,它是蓝色的“e”图标。
![Taskbar](https://istack.dev59.com/LzDS6.webp)
如果您没有或取消了固定,您只需要重新固定它。不幸的是,MicrosoftEdge.exe
不能通过双击运行,创建普通快捷方式也无法工作。您可能在此位置找到它。
![Location](https://istack.dev59.com/CHZTe.webp)
您需要做的就是在开始菜单或搜索栏中搜索Edge。一旦看到Microsoft Edge,请右键单击并固定到任务栏。
![Search](https://istack.dev59.com/Sfi0C.webp)
您可以使用此vbscript运行Microsoft Edge:Run-Micro-Edge.vbs
CreateObject("wscript.shell").Run "%windir%\explorer.exe shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
ParseName
是COM对象而不是PowerShell方法,因此您需要使用小写字母N来调用它,这可能会有所区别。如果我右键单击一个文件夹,我会看到“固定到开始菜单”,但没有“固定到任务栏”。 - Eris