Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“如何取消固定”;图书馆;是否使用Powershell从任务栏创建文件夹?_Powershell - Fatal编程技术网

“如何取消固定”;图书馆;是否使用Powershell从任务栏创建文件夹?

“如何取消固定”;图书馆;是否使用Powershell从任务栏创建文件夹?,powershell,Powershell,我正在修改脚本以包含卸载ChocolateTynnedTaskBarItem功能 这在以下命令下非常有效 # WORKS Uninstall-ChocolateyPinnedTaskBarItem "$env:ProgramFiles\Internet Explorer\iexplore.exe" 但它不适用于任何人 # DOESN'T WORK Uninstall-ChocolateyPinnedTaskBarItem "$env:SystemRoot\explorer.exe" 如何以独

我正在修改脚本以包含
卸载ChocolateTynnedTaskBarItem
功能

这在以下命令下非常有效

# WORKS
Uninstall-ChocolateyPinnedTaskBarItem "$env:ProgramFiles\Internet Explorer\iexplore.exe"
但它不适用于任何人

# DOESN'T WORK
Uninstall-ChocolateyPinnedTaskBarItem "$env:SystemRoot\explorer.exe"
如何以独占方式使用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
  }
}
函数卸载ChocolateTynnedtaskbaritem{
param(
[字符串]$targetFilePath
)
使用targetFilePath:“$targetFilePath`”编写调试“正在运行‘卸载ChocolateTynnedtaskBarItem’”;
if(测试路径($targetFilePath)){
$verb=“从任务栏取消绑定”
$path=拆分路径$targetFilePath
$shell=新对象-com“shell.Application”
$folder=$shell.Namespace($path)
$item=$folder.Parsename((拆分路径$targetFilePath-leaf))
$itemVerb=$item.Verbs()|?{$\.Name.Replace(&,“”)-eq$verb}
如果($itemVerb-eq$null){
Write Host“找不到$item的任务栏谓词。它可能已被取消固定”
}否则{
$itemVerb.DoIt()
} 
写入主机“`$targetFilePath`”已从桌面上的任务栏取消固定
}否则{
$errorMessage=“`$targetFilePath`'不存在,无法从任务栏取消绑定”
}
如果($errorMessage){
写入错误$errorMessage
抛出$errorMessage
}
}

在遇到一个类似的问题后,我的经验让我相信这个问题只发生在Windows 8.x上,而且,恕我直言,这是一个bug

tl;dr:在注册表项
[HKEY_CLASSES_ROOT\CLSID\{52205fd8-5dfb-447d-801a-D0B52F2F83E1}
下,添加注册表项
shellex\ContextMenuHandler\{90AA3A4 E-1CBA-4233-B8BB-535773D484449}

.reg文件版本:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{52205fd8-5dfb-447d-801a-d0b52f2e83e1}\shellex\ContextMenuHandlers\{90AA3A4E-1CBA-4233-B8BB-535773D48449}]
免责声明:
[HKEY_CLASSES_ROOT\CLSID\{52205fd8-5dfb-447d-801a-d0b52f2e83e1}
是受信任的安装程序保护的密钥。请根据您的最佳判断


以下是让我成功的步骤:

为了开始诊断问题,我编写了以下函数,用于检索固定的lnk文件或(可选)lnk文件的目标:

function Get-UserPinnedItems([switch]$Target)
{
    $userPinnedPath = "$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar"
    $shellApp       = New-Object -ComObject 'Shell.Application'
    $items          = $shellApp.Namespace($userPinnedPath).Items() | where { $_.IsLink }

    if ($Target)
    {
        return $items | foreach { $_.GetLink.Target }
    }
    $items
}

在Windows 8.1上使用-Target开关运行上述操作,我得到了以下结果:

PS> Get-UserPinnedItems -Target

Application  : System.__ComObject
Parent       : System.__ComObject
Name         : File Explorer
Path         : ::{52205FD8-5DFB-447D-801A-D0B52F2E83E1}
GetLink      : 
GetFolder    : 
IsLink       : False
IsFolder     : False
IsFileSystem : False
IsBrowsable  : False
ModifyDate   : 12/30/1899 12:00:00 AM
Size         : 0
Type         : System Folder
请注意路径是
:{52205FD8-5DFB-447D-801A-D0B52F2E83E1}
。这显然是文件资源管理器的新CLSID,其可用信息非常少。在注册表(甚至internet)中搜索此guid不会返回很多结果。在Windows 7上,我会返回文件系统路径“C:\Windows\Explorer.exe”这就是为什么我认为这是一个Win8唯一的问题

现在,将项目固定/取消固定到任务栏由具有CLSID{90AA3A4E-1CBA-4233-B8BB-535773D48449}的处理。在注册表中搜索此guid会产生多个结果。大多数情况下,特定文件类型需要固定/取消固定功能

因此,由于文件资源管理器缺少此功能,添加ContextMenuHandler似乎是一个好主意,而且可以肯定的是,它很有魅力,至少对我来说是如此。ymmv。如果它对其他人不起作用,也许它至少会提供一些线索


旁白: OP指出问题出在固定的“Library”文件夹上。我认为这并不完全正确,因为固定的项目有文件浏览器CLSID{52205FD8-5DFB-447D-801A-D0B52F2E83E1},而不是库CLSID{031E4825-7B94-4dc3-B131-E946B44C8DD5}


运行
Shell::{031E4825-7B94-4dc3-B131-E946B44C8DD5}
时总是打开库文件夹,运行
Shell::{52205FD8-5DFB-447D-801A-D0B52F2E83E1}
可能会打开库或This PC文件夹,这取决于用户是否启用了“显示库”选项。基于此,我将文章重命名为“文件资源管理器”而不是“库”"。另外,我想说我使用的是哪个操作系统。

在装有Powershell v3的Windows 7中运行得非常好。您运行的是什么Windows和Powershell版本?我刚刚使用该函数在Win8/Powershell 3.0上删除了一个固定项。固定项很好…非常好。不起作用的是取消固定库文件夹非常好取消固定我的默认lWin 7 Home Premium 64位中的Library文件夹。如果我将动词更改为“Pin到任务栏”,也会恢复该文件夹。以下URL的屏幕截图:您能告诉我您收到了什么错误消息吗?