Tôi đang sửa đổi các tập lệnh Chocolatey để bao gồm chức năng Uninstall-ChocolateyPinnedTaskBarItem
.Làm cách nào để bỏ ghim thư mục "Thư viện" khỏi Thanh tác vụ bằng Powershell?
này hoạt động tốt với các lệnh sau
# WORKS
Uninstall-ChocolateyPinnedTaskBarItem "$env:ProgramFiles\Internet Explorer\iexplore.exe"
Nhưng nó không làm việc với
# DOESN'T WORK
Uninstall-ChocolateyPinnedTaskBarItem "$env:SystemRoot\explorer.exe"
Làm thế nào tôi có thể thoát khỏi những mặc định gắn "Thư viện" thư mục sử dụng Powershell độc quyền?
Đây là tập lệnh Gỡ cài đặt.
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
}
}
Hoạt động hoàn hảo trong Windows 7 với Powershell v3. Bạn đang chạy phiên bản Windows và Powershell nào? –
Tôi vừa sử dụng chức năng này để xóa một mục được ghim trên Win8/PowerShell 3.0. –
các mục được ghim là tốt ... hoạt động tốt. Những gì không hoạt động là bỏ trống *** Thư mục Thư viện *** –