我想使用 chocolatey 从任务栏固定和取消固定程序。我知道我可以使用辅助函数 Install-ChocolateyPinnedTaskBarItem 来固定程序。
例如
安装-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Mozilla Thunderbird\thunderbird.exe"
我收到这些消息
找不到 System.__ComObject 的 TaskBar 动词。它可能已经固定
“C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe”已固定到桌面的任务栏,但 thunderbird 未固定且桌面上没有图标。
我修改了 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?此功能是对先前引脚功能的补充。
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 文件扩展名
安装-ChocolateyFileAssociation ".txt""${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
安装-ChocolateyFileAssociation ".ps1""${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
以下适用于 windows 7 和 windows 10
安装-ChocolateyFileAssociation ".rar""$ProgramsPath\7-Zip\7zFM.exe"
安装-ChocolateyFileAssociation ".zip""$ProgramsPath\7-Zip\7zFM.exe"
Install-ChocolateyFileAssociation ".7z""$ProgramsPath\7-Zip\7zFM.exe"
最佳答案
其中大部分看起来需要作为问题提交给 https://github.com/chocolatey/choco/issues - 看来您发现了一些错误,并且有一个添加取消固定任务栏支持的功能。
您是否介意在项目中重新创建所有这些问题,以便对它们进行分类和处理?谢谢!
关于windows - Chocolatey 和 powershell : pin and unpin programs from task bar and file associations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34861159/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub
之前在培训新生的时候,windows环境下配置opencv环境一直教的都是网上主流的vsstudio配置属性表,但是这个似乎对新生来说难度略高(虽然个人觉得完全是他们自己的问题),加之暑假之后对cmake实在是爱不释手,且这样配置确实十分简单(其实都不需要配置),故斗胆妄言vscode下配置CV之法。其实极为简单,图比较多所以很长。如果你看此文还配不好,你应该思考一下是不是自己的问题。闲话少说,直接开始。0.CMkae简介有的人到大二了都不知道cmake是什么,我不说是谁。CMake是一个开源免费并且跨平台的构建工具,可以用简单的语句来描述所有平台的编译过程。它能够根据当前所在平台输出对应的m
深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal
我在目录“C:\DocumentsandSettings\test.exe”中有一个文件,但是当我用单引号编写命令时`C:\DocumentsandSettings\test.exe(我无法在此框中显示),用于在Ruby中执行命令,我无法这样做,我收到的错误是找不到文件或目录。我尝试用“//”和“\”替换“\”,但似乎没有任何效果。我也使用过系统、IO.popen和exec命令,但所有的努力都是徒劳的。exec命令还使程序退出,这是我不想发生的。提前致谢。 最佳答案 反引号环境就像双引号,所以反斜杠用于转义。此外,Ruby会将空格解
我在安装“redcarpet”gem时遇到以下错误。它在我friend的机器上安装没有问题。(我想安装它来运行yard)ruby版本:1.9.3命令输出:D:\Learning\Common_POM_FW\SampleProjects>yard[error]:Missing'redcarpet'gemforMarkdownformatting.Installitwith`geminstallredcarpet`D:\Learning\Common_POM_FW\SampleProjects>geminstallredcarpetTemporarilyenhancingPATHtoinc
我们正在开发一个需要推送通知的WP8应用程序。为了测试它,我们使用CURL命令行运行推送通知POST请求,确保它实际连接,使用客户端SSL证书进行身份验证并发送正确的数据。我们确实知道,当我们收到对设备的推送时,这项工作是有效的。这是我们一直用于测试目的的CURL命令:curl--certclient_cert.pem-v-H"Content-Type:text/xml"-H"X-WindowsPhone-Target:Toast"-H"X-NotificationClass:2"-XPOST-d"MytitleMysubtitle"https://db3.notify.live.ne
我在Windows7上运行Jekyll时遇到问题。当我运行时jekyll出现以下错误C:\temp\jekyll\kouphax.github.com>jekyllConfigurationfromC:/temp/jekyll/kouphax.github.com/_config.ymlBuildingsite:C:/temp/jekyll/kouphax.github.com->C:/temp/jekyll/kouphax.github.com/_siteunit-testingYouaremissingalibraryrequiredforTextile.Pleaserun:$[s
我正在尝试使用本手册让Jekyll在Windows8x64上运行:RunningJekyllonWindows我正在使用来自rubyinstaller.org的以下两个下载:ruby2.0.0-p0(x64)DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe所以我根据手册设置了Ruby和DevKit(希望它是更新的版本)。我尝试运行一点HelloWorld.rb脚本,它工作正常,路径变量已设置。然后我尝试运行geminstalljekyll并得到以下输出:geminstalljekyll-outputonpastebin.com问题似乎出在名为f
在Windows上通过ruby2.0.0安装iconv时出错通过ruby2.0.0在Windows上安装iconv时出错我正在尝试安装iconv,但是当我运行以下命令时:geminstalliconv我的结果:TemporarilyenhancingPathtoincludeDevKit...Buildingnativeextensions.Thiscouldtakeawhile...Error:Errorinstallingiconv:ERROR:Failedtobuildgemnativeextension.C:/Ruby/Ruby200/bin/ruby.exe-r./s