Archive: [Windows 7] Pin a program to the superbar


[Windows 7] Pin a program to the superbar
I finally found a way to pin exe files to the windows 7 superbar, so I share my method :) .

First, I made this little vbsript (Pin.vbs).

Set objShell = CreateObject("Shell.Application")
set filesystem = CreateObject("scripting.Filesystemobject")
Set objFolder = objShell.Namespace(filesystem.GetParentFolderName(Wscript.Arguments(1)))
Set objFolderItem = objFolder.ParseName(filesystem.GetFileName(WScript.Arguments(1)))
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Wscript.Arguments(0) = "pin" and Replace(objVerb.name, "&", "") = "Pin to taskbar" then
objVerb.DoIt
else
If Wscript.Arguments(0) = "unpin" and Replace(objVerb.name, "&", "") = "Unpin from taskbar" Then
objVerb.DoIt
end if
end if
Next


And I made this two very little functions :

Function PinToTaskbar
SetOutPath $TEMP
File pin.vbs
ExecWait "cscript /b /nologo $TEMP\pin.vbs pin $0"
delete pin.vbs
FunctionEnd

Function UnpinFromTaskbar
SetOutPath $TEMP
File pin.vbs
ExecWait "cscript /b /nologo $TEMP\pin.vbs unpin $0"
delete pin.vbs
FunctionEnd


Usage :

StrCpy $0 '"$PROGRAMFILES32\Mozilla Firefox\Firefox.exe"'
call PinToTaskbar


(same with UnpinFromTaskbar)

Feel free to improve this and, of course, reuse it if you need :).

Note: "Pin to taskbar" and "Unpin from taskbar" may vary with windows language. I only check this on english and french language.

You can find the good strings with this little script :

Set objShell = CreateObject("Shell.Application")
set filesystem = CreateObject("scripting.Filesystemobject")
Set objFolder = objShell.Namespace(filesystem.GetParentFolderName(Wscript.Arguments(0)))
Set objFolderItem = objFolder.ParseName(filesystem.GetFileName(WScript.Arguments(0)))
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
Wscript.Echo objVerb
Next

Verb's should also have a "internal" name that probably does not change with the language, but I'm not going to help you look for it because code like this is evil. The _USER_ should decide what is pinned, not your setup. (There is a reason that the pinned lists don't have a API you can call)


I'm with Anders on this one. This code is evil. Any program doing this on my Windows 7 will get itself uninstalled before it's even opened, followed by a couple of malware scans.


Well, the only user of my setup is me...for now.

Later it will be installed only in the company I work for.
My boss wants this, so I found a (crappy) solution ;) .
But if there is a more "proper" way to pin programs to the superbar, I'm open.

Btw, I agree, this is evil for a public setup.


from my understanding, there's not meant to be a way for an app to pin itself or anything else - it's meant to be done by the user so there shouldn't be any true way of doing it.

-daz