Old 9th December 2009, 05:53   #1
Fab31
Junior Member
 
Join Date: Dec 2009
Posts: 2
[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).

code:
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 :

code:
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 :
code:

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 :

code:
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

Fab31 is offline   Reply With Quote
Old 9th December 2009, 11:24   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
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)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 9th December 2009, 11:32   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 9th December 2009, 17:14   #4
Fab31
Junior Member
 
Join Date: Dec 2009
Posts: 2
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.
Fab31 is offline   Reply With Quote
Old 10th December 2009, 07:54   #5
DrO
 
Join Date: Sep 2003
Posts: 27,873
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
DrO is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump