Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
C# 将Metro应用程序固定到任务栏Windows 10 Powershell_C#_Windows_Powershell - Fatal编程技术网

C# 将Metro应用程序固定到任务栏Windows 10 Powershell

C# 将Metro应用程序固定到任务栏Windows 10 Powershell,c#,windows,powershell,C#,Windows,Powershell,以下代码将在给定AUMID的情况下锁定metro应用程序以启动 如果你改变 -match 'Pin To Start' 不幸的是,将匹配项更改为“固定到任务栏”不起作用。这是怎么回事 function Pin-Taskbar { param( [string]$aumid, [switch]$unpin ) try{ if ($unpin.IsPresent){ ((New-Object -Com S

以下代码将在给定AUMID的情况下锁定metro应用程序以启动

如果你改变

-match 'Pin To Start'
不幸的是,将匹配项更改为“固定到任务栏”不起作用。这是怎么回事

function Pin-Taskbar {    param(
        [string]$aumid,
        [switch]$unpin
    )
    try{
        if ($unpin.IsPresent){
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Path -eq $aumid}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from Taskbar'} | %{$_.DoIt()}
            return "App '$aumid' unpinned from Taskbar"
        }else{
            ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Path -eq $aumid}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to Taskbar'} | %{$_.DoIt()}
            return "App '$aumid' pinned to Taskbar"
        }
    }catch{
        Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
    }
}


Pin-Taskbar king.com.CandyCrushSaga_kgqvnymyfvs32!App

我假设你是一个好公民,不想给用户的任务栏发垃圾邮件

在以前版本的Windows中,您可以使用动词
Pintotaskbar
以编程方式将程序取消/固定到任务栏

$shell = new-object -com "Shell.Application" 
$folder = $shell.Namespace((Join-Path $env:SystemRoot System32\WindowsPowerShell\v1.0))
$item = $folder.Parsename('powershell_ise.exe')
$item.invokeverb('taskbarpin');
这在Windows 10中不再有效。动词
Pintotaskbar
已经不存在了

因此,未经批准的第三方命令提示实用程序 调用被带到生活中-这允许你完全做你想做的事(尽管它不适用于每一个应用程序,尤其是UWP/Metro应用程序)

然而,自Windows10版本1607以来,有一种新的官方方式:添加

请参阅:

您不应该以编程方式告诉用户您的应用程序对他们很重要@TessellatingHeckler必须有一种方法“注意应用程序不能以编程方式将自己固定到任务栏上。该功能严格为用户保留。”我并不是试图向用户发送任务栏垃圾邮件。正如你所说,Win 10中不再存在动词。糟糕的是我只对Win 10和Metro应用程序感兴趣。SysPin不会锁定Metro应用程序。对于Win 10中的metro应用程序,还有其他方法吗?事实并非如此。这个动词仍然存在。只是不是每个人都可以使用。