微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

巧克力和PowerShell:从任务栏和文件关联引脚和取消固定程序

我想使用巧克力从任务栏固定和取消固定程序。 我知道我可以使用助手函数Install-ChocolateyPinnedTaskBarItem来编程程序。

例如Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}Mozilla Thunderbirdthunderbird.exe"我得到这些消息

TaskBar verb not found for System.__ComObject. It may have already been pinned 'C:Program Files (x86)Mozilla Thunderbirdthunderbird.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的源代码,以便打印所有的操作,这是输出

为什么鼻子testing会在Windows 8上留下孤立的PhantomJS进程?

如何configurationChocolatey使用公司代理?

Chocolatey安装path在哪里?

使用巧克力创build你自己的包

我如何设置巧克力将应用程序安装到另一个驱动器上?

Split-path C:Program FilesMozilla Firefox Folder System.__ComObject Item System.__ComObject ItemVerb TaskBar verb not found for System.__ComObject. It may have already been pinned 'C:Program FilesMozilla Firefoxfirefox.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 Thunderbirdthunderbird.exe' has been pinned to the task bar on your desktop`

我在调用函数时犯了一个错误吗?

而且,我还想解除scheme。 巧克力似乎没有任何function来做到这一点。 我从这个线程发现如何从任务栏使用PowerShell解除“库”文件夹? 这个function是上一个引脚function的补充。

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.0Common7IDEdevenv.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 }

以同样的方式,这是行不通的。 我知道我可以使用其他解决scheme,如https://gallery.technet.microsoft.com/ScriptCenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750/ 。 不过,我更喜欢巧克力的东西。 你有什么build议吗?

编辑:在Windows 7和10甚至一些文件关联不起作用。 下面的工作与Windows 7,但不适用于Windows 10

Install-ChocolateyFileAssociation ".html" "$ProgramsPathMozilla Firefoxfirefox.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" "$ProgramsPath7-Zip7zFM.exe" Install-ChocolateyFileAssociation ".zip" "$ProgramsPath7-Zip7zFM.exe" Install-ChocolateyFileAssociation ".7z" "$ProgramsPath7-Zip7zFM.exe"

如何完全离线安装一个巧克力包?

如何重新编译Chocolatey虚拟包?

转向现有的服务器安装巧克力

在USB驱动器巧克力设置

如果组策略阻止7zip,如何使用Chocolatey?

其中大部分看起来像需要作为问题进入https://github.com/chocolatey/choco/issues – 看来你已经发现了一些错误,并有一个功能添加解除任务栏支持

你是否介意在项目中创建所有这些问题,以便他们能够进行分类和工作? 谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐