My application's instance icon changes to the main executable file's icon when I pin it to the taskbar

194 Views Asked by At

I am running two instances of the same executable file with different command-line arguments for the target path. As shown below

enter image description here enter image description here

During runtime, I have set different icons for each instance, and I have set the default icon for the main executable file under the project properties.

The following code is used to launch the main executable file in the launcher application:

Call Shell(Chr(34) & My.Application.Info.DirectoryPath & "\main.exe" & Chr(34) & " " & VB.Command(), AppWinStyle.NormalFocus)

In the main executable file, the code below is used to load the icons based on the command-line argument:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If VB.Command() = "Test1" Then
                Me.Icon = New Icon("path of icon1")
        ElseIf VB.Command() = "Test2" Then
                Me.Icon = New Icon("path of icon2")
        End If
End Sub

While running two instances, the icons are loaded properly to the taskbar. However, if I pin a running instance to the taskbar, the icon changes to the main application icon that I have set under the project properties.

enter image description here enter image description here

I have tested this behavior with the Chrome executable file by creating a new profile and pinning it to the taskbar while running. When observed, the jumplist had a reference to the new profile (i.e., the target path command-line argument was present).

enter image description here enter image description here

However, when I run one of my application instances and check it, it has a reference to the main executable file.

enter image description here enter image description here

Observations: If I pin the instance to the taskbar without running it, the icons do not change. Additionally, I can see its command-line argument in the property window, as shown below:

enter image description here enter image description here

I would like to know what causes the icon of a running instance to change when it is pinned to the taskbar.

I want to keep the instance's icon even after opening and pinning it to the taskbar, and I want the target path to include its command-line argument. How can I achieve this programmatically?

0

There are 0 best solutions below