使用Powershell将应用程序或快捷方式固定到任务栏
我试过这个:使用Powershell将应用程序或快捷方式固定到任务栏,powershell,Powershell,我试过这个: $shell = new-object -com "Shell.Application" $folder = $shell.Namespace('C:\Windows') $item = $folder.Parsename('notepad.exe') $verb = $item.Verbs() | ? {$_.Name -eq 'Pin to Tas&kbar'} if ($verb) {$verb.DoIt()} 这
$shell = new-object -com "Shell.Application"
$folder = $shell.Namespace('C:\Windows')
$item = $folder.Parsename('notepad.exe')
$verb = $item.Verbs() | ? {$_.Name -eq 'Pin to Tas&kbar'}
if ($verb) {$verb.DoIt()}
这是:
param (
[parameter(Mandatory=$True, HelpMessage="Target item to pin. Ex: C:\windows\notepad.exe")]
[ValidateNotNullOrEmpty()]
[string] $Target
)
if (!(Test-Path $Target)) {
Write-Warning "$Target does not exist"
break
}
$KeyPath1 = "HKCU:\SOFTWARE\Classes"
$KeyPath2 = "*"
$KeyPath3 = "shell"
$KeyPath4 = "{:}"
$ValueName = "ExplorerCommandHandler"
$ValueData =
(Get-ItemProperty `
("HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + `
"CommandStore\shell\Windows.taskbarpin")
).ExplorerCommandHandler
$Key2 = (Get-Item $KeyPath1).OpenSubKey($KeyPath2, $true)
$Key3 = $Key2.CreateSubKey($KeyPath3, $true)
$Key4 = $Key3.CreateSubKey($KeyPath4, $true)
$Key4.SetValue($ValueName, $ValueData)
$Shell = New-Object -ComObject "Shell.Application"
$Folder = $Shell.Namespace((Get-Item $Target).DirectoryName)
$Item = $Folder.ParseName((Get-Item $Target).Name)
$Item.InvokeVerb("{:}")
$Key3.DeleteSubKey($KeyPath4)
if ($Key3.SubKeyCount -eq 0 -and $Key3.ValueCount -eq 0) {
$Key2.DeleteSubKey($KeyPath3)
}
但从1903年起,一切似乎都不起作用
有人有可能解决这个问题吗?
这些似乎在1803年以前就起作用了。
我必须补充更多细节,因为这篇文章大部分是代码。1803还是1903?其中一个是打字错误?您可以使用问题下方的链接进行更正,并添加您可能忘记的任何其他相关信息…查看此链接-