views:

249

answers:

4

When an application deployed by ClickOnce AutoUpdate is automatically updated on Windows 7, the application becomes unpinnned from the taskbar. Is there a way to stop it from becoming unpinned?

+1  A: 

When the ClickOnce application is not installed it most likely impossible to achieve this. When it's installed; i'm not sure.

A ClickOnce application is downloaded to the users' temporary directory. When the application downloads the latest version, this version is stored in a new sub directory and not overwritten as which is the case with 'normal' application updates.

Rhapsody
A: 

I don't know about keeping it from being unpinned but there is a way using a vbs script to pin an exe which isn't supposed to be doable by code:

Call AddToTaskbar("C:\temp\", "MyExe.exe")

Function AddToTaskbar (Path, File)
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(Path)
    Set objFolderItem = objFolder.ParseName(File)
    Set colVerbs = objFolderItem.Verbs

    For Each objVerb in colVerbs
        If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then 
            'WScript.Echo objVerb
            objVerb.DoIt
        End If
    Next        
End Function

This essentially relies on the right click menu of an exe having the "Pin to Taskbar" entry. It unfortunately makes it english specific unless someone has a list of all translations.

PeteT
The problem is you don't want to pin the [exe] file from a CLickOnce application. If you run it by running the [exe] instead of the appref-ms file, it won't run as a ClickOnce app and look for updates and check the deployment files, etc.
RobinDotNet
+1  A: 

I'm not seeing this problem at all. I'm assuming you manually pinned the application to the task bar the first time you ran it.

Are you targeting .NET 3.5 (SP-1)? Are you having ClickOnce create the desktop shortcut for you or are you doing it programmatically? Does the desktop shortcut disappear?

Does it disappear from the taskbar every time an update is released, or just every so often?

RobinDotNet

RobinDotNet
Yes, I manually pinned the application. It disappears every time an update is released.
RyanTM
Any answers for my other questions?
RobinDotNet
A: 

I'm not sure how Windows 7 handles it, but I use code similar to this to copy the appref-ms to the startup folder on the start menu. I think my code (on my work machine and I'm off for the weekend) also has a check for if this is a new install so it does not change the shortcut if it is an update.

AdmSteck
With .NET 3.5 SP-1, they added the ability to have a shortcut added to the desktop created automatically. When they did that, they also added a bit that removes the shortcut every time an update is issued, and if you have their checkbox checked, it puts it back. So if you are copying their shortcut to your desktop (as we do, so it's the actual C/O shortcut), you have to do it every time or it disappears. Doesn't matter what version of .NET you target; will happen if machine has .NET 3.5 SP-1 installed. Just FYI.
RobinDotNet