BLACK THANOS
asked on
How do I pin an application to the taskbar in windows 7 programatically.
Good evening Experts,
Is there a quick and dirty way to pin and un-pin applications to the taskbar either via command line or vbscript. I dont want some overly complicated VBA, C++, C#, or Java based solution that I have to study for hours and hours to understand. Just something simple that will allow me to pin or un-pin applications to the taskbar.
Regards,
Regis
Is there a quick and dirty way to pin and un-pin applications to the taskbar either via command line or vbscript. I dont want some overly complicated VBA, C++, C#, or Java based solution that I have to study for hours and hours to understand. Just something simple that will allow me to pin or un-pin applications to the taskbar.
Regards,
Regis
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Rob, thanks for chiming in!
@Regis, if Rob's linked solution suits your needs please ensure that you at least split the credit between our comments so that he actually receives the proper credit for his great work. Thanks!
@Regis, if Rob's linked solution suits your needs please ensure that you at least split the credit between our comments so that he actually receives the proper credit for his great work. Thanks!
ASKER
I like the way you guys collaborate. I will look at the solution and get back to you asap.
Good to hear from you too Run5k
Good to hear from you too Run5k
Rob, I started monitoring the other question to learn a few tips. As I said, I am definitely not a VBScript guru so I certainly appreciate your advice! In your opinion, what would be the easiest was to actually implement something like this on an end-user's machine? Perhaps utilizing a RunOnce registry key?
ASKER
Run5k, I ran the code snippet that you referrred to:
,but I get the following error:
Microsoft VBScript runtime error: Object doesn't support this property or method: 'objFile.Parent'
Can you or RobSamson shed some light on this??
,but I get the following error:
Microsoft VBScript runtime error: Object doesn't support this property or method: 'objFile.Parent'
Can you or RobSamson shed some light on this??
arrFileNames = Array( _
"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe", _
"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe", _
"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe", _
"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShellApp = CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
For Each strFilePath In arrFileNames
Set objFile = objFSO.GetFile(strFilePath)
Set objFolder = objShellApp.Namespace(objFile.Parent)
Set objFolderItem = objFolder.ParseName(objFile.Name)
Set colVerbs = objFolderItem.Verbs
For Each objVerb In colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next
Next
Regis,
I will defer to Rob's expertise in the VBScript department. He is easily the EE community's foremost expert within that topic area, and is typically very active on the boards. I'm sure he will reply back to you rather soon.
I will defer to Rob's expertise in the VBScript department. He is easily the EE community's foremost expert within that topic area, and is typically very active on the boards. I'm sure he will reply back to you rather soon.
Hi guys, sorry, I was away for the weekend.
Regis, please try this, in which I have just added a check for the file before attempting to bind to it.
Also, if you only need to pin one item, you only need one element in the array.
I have added two WScript.Echo statements which you are welcome to comment out or delete when you have finished testing.
Regards,
Rob.
Regis, please try this, in which I have just added a check for the file before attempting to bind to it.
Also, if you only need to pin one item, you only need one element in the array.
I have added two WScript.Echo statements which you are welcome to comment out or delete when you have finished testing.
Regards,
Rob.
arrFileNames = Array( _
"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe" _
)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShellApp = CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
For Each strFilePath In arrFileNames
If objFSO.FileExists(strFilePath) = True Then
Set objFile = objFSO.GetFile(strFilePath)
Set objFolder = objShellApp.Namespace(objFile.Parent)
Set objFolderItem = objFolder.ParseName(objFile.Name)
Set colVerbs = objFolderItem.Verbs
For Each objVerb In colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next
WScript.Echo strFilePath & " has been pinned."
Else
WScript.Echo "Could not find " & strFilePath
End If
Next
ASKER
I still get this error:
C:\INSTALL\Untitled6.vbs(2 4, 3) Microsoft VBScript runtime error: Object doesn't support this property or method: 'objFile.Parent'
at:
Set objFolder = objShellApp.Namespace(objF ile.Parent )
C:\INSTALL\Untitled6.vbs(2
at:
Set objFolder = objShellApp.Namespace(objF
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rob, we definitely appreciate the input! As I said earlier, in your opinion what would be the best way to actually implement something like this on an end-user's machine? Perhaps utilizing a RunOnce registry key in some format?
RunOnce would run before the user interface loaded, so I'm not sure that would be able to pin items.
I would probably just use the script at Logon, but also write a flag somewhere that would tell the script whether the items had already been pinned, to avoid pinning it everytime....although I don't think that would be a problem anyway.
Rob.
I would probably just use the script at Logon, but also write a flag somewhere that would tell the script whether the items had already been pinned, to avoid pinning it everytime....although I don't think that would be a problem anyway.
Rob.
ASKER
I ran the updated script and it came back with no errors, but I didnt actually see the pinned item on the taskbar.
Also,
I changed C:\Program Files\Microsoft Office\Office14\winword.ex e
To
C:\Program Files (x86)\Microsoft Office\Office14\winword.ex e , because my version of office is the 32bit versions on my Windows 7 64 bit operating systems.
Also,
I changed C:\Program Files\Microsoft Office\Office14\winword.ex
To
C:\Program Files (x86)\Microsoft Office\Office14\winword.ex
It did work for me....does it make any difference if you run cmd.exe by right-clicking, then select "Run As Administrator", then type the following:
c:\windows\syswow64\cscrip t.exe c:\scripts\PinItem.vbs
Rob.
c:\windows\syswow64\cscrip
Rob.
ASKER
I tried this :
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>CD ..
C:\Windows>CD SYSWOW64
C:\Windows\SysWOW64>cscrip t.exe "N:\INSTALL HOME\scratch.vbs"
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Windows\System32\notepa d.exe has been pinned.
C:\Windows\SysWOW64>
I did it as "RUN AS ADMINISTRATOR"
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>CD ..
C:\Windows>CD SYSWOW64
C:\Windows\SysWOW64>cscrip
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Windows\System32\notepa
C:\Windows\SysWOW64>
I did it as "RUN AS ADMINISTRATOR"
ASKER
It still didnt pin the item. You may have noticed I tried something as simple as Notepad.exe
ASKER
Stop the presses. I know what the problem is........!!!!!!!!!!!!!!!! !!!
LOL! Do tell.....
ASKER
RobSamson,
Your script is working at advertised.
It actually pinned word and notepad to the start menu.
However, this is not the solution I asked for. If you will refer to the original post, it requires a solution to pin to the taskbar , not the startmenu. Is this a simple change?
Your script is working at advertised.
It actually pinned word and notepad to the start menu.
However, this is not the solution I asked for. If you will refer to the original post, it requires a solution to pin to the taskbar , not the startmenu. Is this a simple change?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rob, this needs to run with full admin privileges? In other words, could it be placed within the C:\ProgramData\Microsoft\W indows\Sta rt Menu\Programs\Startup folder and still run effectively?
No, it won't need to run with admin rights.....that was just a test....the problem was that we were pinning items to the wrong place, so we thought it didn't work.
It should therefore still work fine if it is placed in that location.
Rob.
It should therefore still work fine if it is placed in that location.
Rob.
ASKER
RobSampson, you and Run5k are premo mucho smarto. It works like a charm. Guys, how should I split the points.
Honestly, please give Rob all of the credit. I'm always glad to help, but in this instance I simply pointed the VBScript guru in your direction!
I'm fine with whatever you feel is appropriate. Thanks Run5k for your input.
Rob.
Rob.
ASKER
RobSampson and Run5k exemplfy excellence for the Experts Exchange Community.
Regis T. Hyde
Doctoral Learner
BSB/IS, MIS
Regis T. Hyde
Doctoral Learner
BSB/IS, MIS
ASKER
I wouldnt have gotten to RobSamspon if not for you Run5k, so I allocated the points I thought appropriate.
Regards,
Regis
Regards,
Regis
Thank you for the kind words... always glad to help!
The code there will pin items. I haven't yet tested a scenario to unpin items, but I can try to assist with that if required. I won't be able to do any testing until early next week though.
Regards,
Rob.