我知道通过代码实现是可能的,因为其他应用程序(如comodo)已经做到了,而不需要我将图标拖放到那里。 对于将快捷方式固定到任务栏,我学到了可以在此文件夹中设置快捷方式:
C:\Users\Username\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
是否有类似托盘的东西?或者有我可以使用代码的选项。
C:\Users\Username\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
是否有类似托盘的东西?或者有我可以使用代码的选项。
param(
[Parameter(Mandatory=$true,HelpMessage='The name of the program')][string]$ProgramName,
[Parameter(Mandatory=$true,HelpMessage='The setting (2 = show icon and notifications 1 = hide icon and notifications, 0 = only show notifications')]
[ValidateScript({if ($_ -lt 0 -or $_ -gt 2) { throw 'Invalid setting' } return $true})]
[Int16]$Setting
)
$encText = New-Object System.Text.UTF8Encoding
[byte[]] $bytRegKey = @()
$strRegKey = ""
$bytRegKey = $(Get-ItemProperty $(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath).IconStreams
for($x=0; $x -le $bytRegKey.Count; $x++)
{
$tempString = [Convert]::ToString($bytRegKey[$x], 16)
switch($tempString.Length)
{
0 {$strRegKey += "00"}
1 {$strRegKey += "0" + $tempString}
2 {$strRegKey += $tempString}
}
}
[byte[]] $bytTempAppPath = @()
$bytTempAppPath = $encText.GetBytes($ProgramName)
[byte[]] $bytAppPath = @()
$strAppPath = ""
Function Rot13($byteToRot)
{
if($byteToRot -gt 64 -and $byteToRot -lt 91)
{
$bytRot = $($($byteToRot - 64 + 13) % 26 + 64)
return $bytRot
}
elseif($byteToRot -gt 96 -and $byteToRot -lt 123)
{
$bytRot = $($($byteToRot - 96 + 13) % 26 + 96)
return $bytRot
}
else
{
return $byteToRot
}
}
for($x = 0; $x -lt $bytTempAppPath.Count * 2; $x++)
{
If($x % 2 -eq 0)
{
$curbyte = $bytTempAppPath[$([Int]($x / 2))]
$bytAppPath += Rot13($curbyte)
}
Else
{
$bytAppPath += 0
}
}
for($x=0; $x -lt $bytAppPath.Count; $x++)
{
$tempString = [Convert]::ToString($bytAppPath[$x], 16)
switch($tempString.Length)
{
0 {$strAppPath += "00"}
1 {$strAppPath += "0" + $tempString}
2 {$strAppPath += $tempString}
}
}
if(-not $strRegKey.Contains($strAppPath))
{
Write-Host Program not found. Programs are case sensitive.
break
}
[byte[]] $header = @()
$items = @{}
for($x=0; $x -lt 20; $x++)
{
$header += $bytRegKey[$x]
}
for($x=0; $x -lt $(($bytRegKey.Count-20)/1640); $x++)
{
[byte[]] $item=@()
$startingByte = 20 + ($x*1640)
$item += $bytRegKey[$($startingByte)..$($startingByte+1639)]
$items.Add($startingByte.ToString(), $item)
}
foreach($key in $items.Keys)
{
$item = $items[$key]
$strItem = ""
$tempString = ""
for($x=0; $x -le $item.Count; $x++)
{
$tempString = [Convert]::ToString($item[$x], 16)
switch($tempString.Length)
{
0 {$strItem += "00"}
1 {$strItem += "0" + $tempString}
2 {$strItem += $tempString}
}
}
if($strItem.Contains($strAppPath))
{
Write-Host Item Found with $ProgramName in item starting with byte $key
$bytRegKey[$([Convert]::ToInt32($key)+528)] = $setting
Set-ItemProperty $($(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath) -name IconStreams -value $bytRegKey
}
}
使用您选择的名称将其保存为ps1文件。
打开组策略管理MMC。选择您选择的组策略对象,右键单击并选择"编辑"。在编辑器中,导航到"用户配置 > Windows设置 > 脚本 > 登录",然后单击"显示属性"。转到PowerShell选项卡,单击"查看文件"。
将刚才创建的脚本复制到刚刚打开的资源管理器窗口中,然后关闭该窗口。
在登录脚本属性窗口中,添加一个新的PowerShell脚本,在脚本名称中输入您使用的脚本名称(例如:NotifyIcon.ps1),然后在参数中输入程序名称(区分大小写!)后跟要使用的设置:
0 = 仅显示通知 1 = 隐藏图标和通知 2 = 显示图标和通知 <--- 您需要的
例如,如果您需要始终显示RealVNC服务器,则应输入:
winvnc4.exe 2
作为参数
您可以以几种不同的方式找出可执行文件的名称,例如打开运行对话框并键入msconfig,查看启动程序,手动导航到安装目录C:\Program Files {您的程序},或尝试通过查看任务管理器中正在运行的进程来匹配所需的程序。十有八九会成功。
为使此操作起作用,用户必须先运行应用程序,然后正确注销,以便explorer.exe有机会将更新的通知区域历史记录写入注册表。在随后的登录中,脚本应成功地找到历史记录中的程序,并将其设置为始终显示。
您还可以尝试从PowerShell提示符手动运行脚本进行调试,但在运行之前必须关闭explorer.exe('taskkill /f /im explorer.exe'),否则explorer不会看到您的更新,在退出时会覆盖它。
我不对此过程负责。我没有编写它,我只是找到了它。脚本的功劳归Micah Rowland,GPO的功劳归Geoff Kendal。
由于声望不足,无法链接到原始作者,除了开头提到的一个。
HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify
请查看这里。
微软明确表示,这是用户决定而不是可以通过编程来实现的决定。是的,有各种工具可以在内部进行修改以实现此目的,但没有受支持的方法可以实现您所需的功能。