我想使用chocolatey来固定和取消任务栏中的程序。我知道我可以使用辅助函数Install-ChocolateyPinnedTaskBarItem
来固定程序。
例如
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Mozilla Thunderbird\thunderbird.exe"
我收到这些消息
TaskBar verb not found for System.__ComObject. It may have already been pinned
'C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe' has been pinned to the task bar on your desktop however thunderbird is not pinned and there is no icon on the desktop.
我修改了Install-ChocolateyPinnedTaskBarItem的源代码,以便打印所有操作,这是输出
Split-path C:\Program Files\Mozilla Firefox
Folder System.__ComObject
Item System.__ComObject
ItemVerb
TaskBar verb not found for System.__ComObject. It may have already been pinned
'C:\Program Files\Mozilla Firefox\firefox.exe' has been pinned to the task bar on your desktop
Split-path C:\Program Files (x86)\Mozilla Thunderbird
Folder System.__ComObject
Item System.__ComObject
ItemVerb
TaskBar verb not found for System.__ComObject.
'C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe' has been pinned to the task bar on your desktop`
我在调用函数时犯了错误吗?
此外,我还想解开节目。似乎巧克力没有任何功能来做到这一点。我从这个帖子How to unpin "Library" folder from Task Bar using Powershell?找到了这个函数,它是前一个pin函数的补充。
function Uninstall-ChocolateyPinnedTaskBarItem {
<# .SYNOPSIS
Removes an item from the task bar linking to the provided path.
.PARAMETER TargetFilePath
The path to the application that should be launched when clicking on the task bar icon.
.EXAMPLE
Uninstall-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
This will remove the Visual Studio task bar icon.
#>
param(
[string] $targetFilePath
)
Write-Debug "Running 'Uninstall-ChocolateyPinnedTaskBarItem' with targetFilePath:`'$targetFilePath`'";
if (test-path($targetFilePath)) {
$verb = "Unpin from Taskbar"
$path= split-path $targetFilePath
$shell=new-object -com "Shell.Application"
$folder=$shell.Namespace($path)
$item = $folder.Parsename((split-path $targetFilePath -leaf))
$itemVerb = $item.Verbs() | ? {$_.Name.Replace("&","") -eq $verb}
if($itemVerb -eq $null){
Write-Host "TaskBar verb not found for $item. It may have already been unpinned"
} else {
$itemVerb.DoIt()
}
Write-Host "`'$targetFilePath`' has been unpinned from the task bar on your desktop"
} else {
$errorMessage = "`'$targetFilePath`' does not exist, not able to unpin from task bar"
}
if($errorMessage){
Write-Error $errorMessage
throw $errorMessage
}
以同样的方式,这不起作用。 我知道我可以使用其他解决方案https://gallery.technet.microsoft.com/ScriptCenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750/。但是,我更喜欢使用巧克力制作的所有东西。 你有什么建议吗?
编辑: 在Windows 7和10甚至一些文件关联不起作用。 以下适用于Windows 7但不适用于Windows 10
Install-ChocolateyFileAssociation ".html" "$ProgramsPath\Mozilla Firefox\firefox.exe"
以下内容仅适用于Windows 7,仅适用于.ps1文件扩展名
Install-ChocolateyFileAssociation ".txt" "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
Install-ChocolateyFileAssociation ".ps1" "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
以下适用于Windows 7和Windows 10
Install-ChocolateyFileAssociation ".rar" "$ProgramsPath\7-Zip\7zFM.exe"
Install-ChocolateyFileAssociation ".zip" "$ProgramsPath\7-Zip\7zFM.exe"
Install-ChocolateyFileAssociation ".7z" "$ProgramsPath\7-Zip\7zFM.exe"
答案 0 :(得分:0)
其中大部分内容似乎都需要考虑到问题https://github.com/chocolatey/choco/issues - 您似乎发现了一些错误并且具有添加取消固定任务栏支持的功能。
您是否介意在项目中创建所有这些问题,以便对它们进行分类和处理?谢谢!