14

Chocolateyスクリプトを変更してUninstall-ChocolateyPinnedTaskBarItem機能を組み込みます。

これは、次のコマンドでうまく機能します

# 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
  }
}
4

1 に答える 1