Announcement

Collapse
No announcement yet.

Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

    I would like run a VBScript that creates a specific Shortcut file and pin it to the users bottom taskbar.

    I manually created a Shortcut file (*.lnk) and drag it to the taskbar and it works.

    Here's my Target path:


    "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf"

    My problem is the Acrobat. Everyone has a different version.

    Like...

    Acrobat 8.0
    Acrobat 9.0
    Acrobat 10.0
    Acrobat 11.0

    Is there some kind of wildcard we can use?

    I tried this and it did not work.

    "C:\Program Files (x86)\Adobe\Acrobat "*"\Acrobat\Acrobat.exe" "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf"


    Also, I found this link below.

    http://wayneye.com/Blog/Programmatic...askbar-on-Win7


    That it will pin a specific Shortcut file to the bottom taskbar. Anyway we can modify it so it can work like this....


    1.) User Logs into he/she computer.
    2.) It will create a Shortcut file using the user's Acrobat version.
    3.) Then it will pinned the Shortcut file to the bottom taskbar.


    Please help!

  • #2
    Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

    Well, I'm not sure if it's the same in VBscript, but for a batch file, the correct syntax for that folder would be acroba~1. This means it will select the first folder with those same six letters, no matter what may succeed it.

    Comment


    • #3
      Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

      If you are on a Domain, push out version 11. v8 is out of date and I think no longer supported. v9 has the last supported update released on a machine I updated yesterday. 9.5.4 if memory serves me correct.
      1 1 was a racehorse.
      2 2 was 1 2.
      1 1 1 1 race 1 day,
      2 2 1 1 2

      Comment


      • #4
        Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

        Originally posted by biggles77 View Post
        If you are on a Domain, push out version 11. v8 is out of date and I think no longer supported. v9 has the last supported update released on a machine I updated yesterday. 9.5.4 if memory serves me correct.
        Hi,

        I'm not understanding what you are saying.

        Comment


        • #5
          Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

          Originally posted by Shazam View Post
          Hi,

          I'm not understanding what you are saying.
          What he's saying is, if your network is on a domain (as opposed to a workgroup), you can use group policy to install Acrobat Reader 11 on all connected computers. Get everyone on the same version and there's no need for wild cards.

          Comment


          • #6
            Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

            Originally posted by Bertmax View Post
            What he's saying is, if your network is on a domain (as opposed to a workgroup), you can use group policy to install Acrobat Reader 11 on all connected computers. Get everyone on the same version and there's no need for wild cards.
            Thanks for replying.

            That's not possible. We have a mix environment on our Domain network. We have Adobe 8-11 standards. And some Adobe readers. If we were just using Adobe Reader then it will work but we are not.
            Last edited by Shazam; 30th May 2014, 14:07.

            Comment


            • #7
              Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

              You can make use of the present file extension association on the computer. Then you don't have to 'pin' the adobe executable, you can use cmd.exe.
              Code:
              C:\Windows\System32\cmd.exe /c "start ""/b "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf""

              Originally posted by Shazam View Post
              Thanks for replying.

              That's not possible. We have a mix environment on our Domain network. We have Adobe 8-11 standards. And some Adobe readers. If we were just using Adobe Reader then it will work but we are not.
              Why do you prefere to use Adobe Acrobat to open a PHONELST.pdf ? You still could install or upgrade Adobe Reader or Nitro Reader on the clients next to Adobe Acrobat.

              /Rems

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                Originally posted by Rems View Post
                You can make use of the present file extension association on the computer. Then you don't have to 'pin' the adobe executable, you can use cmd.exe.
                Code:
                C:\Windows\System32\cmd.exe /c "start ""/b "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf""


                Why do you prefere to use Adobe Acrobat to open a PHONELST.pdf ? You still could install or upgrade Adobe Reader or Nitro Reader on the clients next to Adobe Acrobat.

                /Rems
                Thank you so much for replying Rems.

                The reason we use Acrobat because is to sign documents, like, time-sheets, contracts, memos, etc. Every user here at the company has a digital signature created for them. And with those digital signatures some users are restricted to open certain documents (PFX, Certificates). This has been a standard here for awhile. And management wants to keep everything standard.

                The easy way out of this is to create a login script that the PHONELIST.pdf will always appear on the user's desktop. BUT there's a somewhat preference with that. When users have multiple windows open on their desktop and if they wanted to look at the phone list pdf file they will have to click on “Show Desktop” and that will minimize all their windows so they can click on the PHONELIST.pdf shortcut. I know it sounds lazy or just plain ridiculous but people are people.

                Please look at the attachment. If somehow we can programmatically get the custom shortcut to pin on the task bar that’ll be great.
                As you can see on the jpeg photo, by having that shortcut pinned to the taskbar…the users don’t have to minimize all their windows.
                The hardest part of the code is probably figuring out what version of Acrobat are the users using on their computers. Maybe the VBS file can do a resume error. So if this fails…

                C:\Program Files (x86)\Adobe\Acrobat 8.0\ Acrobat\Acrobat.exe

                Then go to find this path
                C:\Program Files (x86)\Adobe\Acrobat 9.0\ Acrobat\Acrobat.exe

                If fails again find this path
                C:\Program Files (x86)\Adobe\Acrobat 10.0\ Acrobat\Acrobat.exe

                Or this one
                C:\Program Files (x86)\Adobe\Reader 9.0\Reader\ AcroRd32.exe

                And this one
                C:\Program Files (x86)\Adobe\Reader 11.0\Reader\ AcroRd32.exe

                Please let me know if this is possible.
                Attached Files
                Last edited by Shazam; 3rd June 2014, 16:00.

                Comment


                • #9
                  Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                  Originally posted by Shazam View Post
                  Please look at the attachment . by having that shortcut pinned to the taskbar…the users don’t have to minimize all their windows.
                  If somehow we can programmatically get the custom shortcut to pin on the task bar that’ll be great.
                  The hardest part of the code is probably figuring out what version of Acrobat are the users using on their computers.
                  You run the vbs script as user logon script,
                  Code:
                  Set WshShell = CreateObject("WScript.Shell")
                  Set objShell = CreateObject("Shell.Application")
                  
                  strTartgetFile = "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf"
                  
                  ShortcutName   = "PHONELST"
                  ShortcutFolder = WshShell.SpecialFolders.Item("Desktop")
                  ShortcutFile = ShortcutName & ".lnk"
                  
                  call PinToTaskbar("unpin")
                  
                  FilePath = ShortcutFolder & "\" & ShortcutFile
                  
                  With WshShell.CreateShortcut(ShortcutFile)
                     .TargetPath = GetProgramAssocWith("PDF")
                     .Arguments = """" & strTartgetFile & """"
                     .WorkingDirectory = "."
                     .IconLocation = "imageres.dll, 124"
                     .Save
                  End With
                  
                  PinToTaskbar("pin")
                  
                  '# uncommend the next three line if you'd like the pinned shortcut to be removed from the desktop
                  ' WScript.Sleep 950
                  ' Set objFSO = CreateObject("Scripting.FileSystemObject")
                  ' objFSO.DeleteFile(FilePath), true
                  
                  wscript.quit
                  
                  Function GetProgramAssocWith(strExt)
                     Const HKCR=&H80000000
                     Const HKCU=&H80000001
                     Set objReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
                  
                     strExt = Replace(strExt,"*","")
                     If Left(strExt,1) <> "." Then strExt = "." & strExt
                  
                     strPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & strExt & "\UserChoice"
                     objReg.GetExpandedStringValue HKCU, strPath, "Progid", strValue
                     If IsNull(strValue) Then
                       objReg.GetExpandedStringValue HKCR, strExt, strEntry, strValue
                     End If
                     If IsNull(strValue) Then wscript.quit
                  
                     strPath = strValue & "\shell\open\command"
                     objReg.GetExpandedStringValue HKCR, strPath, strEntry, strValue
                     strValue = Replace(strValue, """", "")
                  
                   ' http://www.akaplan.com/blog/2010/12/vbscript-to-get-program-associated-with-file-extension/
                     If InStr(strValue,"rundll") Then
                  	Dim tArray
                  	tArray = split(strValue,",")
                  	GetProgramAssocWith = replace(tArray(0),"rundll32.exe","")
                     Else
                  	strValue = LCase(strValue)
                  	GetProgramAssocWith = Left(strValue,instrrev(strValue,".exe")+3)
                     End If
                  End Function
                  
                  Sub PinToTaskbar(choice)
                  
                     On Error Resume Next
                  
                     If Lcase(choice) = "unpin" then
                  
                       LnkFolder = WshShell.SpecialFolders.Item("AppData")
                       LnkFolder = LnkFolder & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
                       LnkFile = ShortcutName & ".lnk"
                  
                       Set objFolder = objShell.Namespace(LnkFolder)
                       Set objFolderItem = objFolder.ParseName(LnkFile)
                       Set colVerbs = objFolderItem.Verbs 
                       For Each objVerb in colVerbs
                         Select Case Replace(objVerb.name, "&", "")
                           case "Unpin from Taskbar" objVerb.DoIt
                           case "other language ..." objVerb.DoIt
                           case "other language ..." objVerb.DoIt
                           case "other language ..." objVerb.DoIt
                         End Select
                       Next
                  
                     ElseIf Lcase(choice) = "pin" then
                  
                       Set objFolder = objShell.Namespace(ShortcutFolder)
                       Set objFolderItem = objFolder.ParseName(ShortcutFile)
                       Set colVerbs = objFolderItem.Verbs
                       For Each objVerb in colVerbs
                         Select Case Replace(objVerb.name, "&", "")
                           case "Pin to Taskbar" objVerb.DoIt
                           case "Ajouter au menu Démarrer" objVerb.DoIt
                           case "Aggiungi a menu Start" objVerb.DoIt
                           case "An Startmenü anheften" objVerb.DoIt
                           case "Aan het menu Start vastmaken" objVerb.DoIt
                           case "Associar ao Menu Iniciar" objVerb.DoIt
                           case "Anclar al menú Inicio" objVerb.DoIt
                         End Select
                       Next
                     End If
                  End Sub
                  /Rems
                  Last edited by Rems; 14th June 2014, 07:53.

                  This posting is provided "AS IS" with no warranties, and confers no rights.

                  __________________

                  ** Remember to give credit where credit's due **
                  and leave Reputation Points for meaningful posts

                  Comment


                  • #10
                    Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                    Hi rems,

                    Thank you for the code. I ran your code and I'm getting an error message. Please look at the attachment.
                    Attached Files

                    Comment


                    • #11
                      Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                      From your file copy the lines 11 to 15 and show me what exactly is on these lines please.


                      http://www.computerperformance.co.uk...e_800A0005.htm
                      Usually this is a syntax error

                      /Rems

                      This posting is provided "AS IS" with no warranties, and confers no rights.

                      __________________

                      ** Remember to give credit where credit's due **
                      and leave Reputation Points for meaningful posts

                      Comment


                      • #12
                        Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                        It might be the way I'm saving your code in a vbs file. I took a screen shot of the message. Please look at the attachment.

                        It's forcing me to save it in Unicode. Do you think that might be changing the syntax?

                        Is this what you meant copy the lines from my file 11 to 15?


                        ShortcutFile = ShortcutFolder & "\" & ShortcutName & ".lnk"

                        With WshShell.CreateShortcut(ShortcutFile)
                        .TargetPath = strAPP
                        .Arguments = """" & strTartgetFile & """"
                        .WorkingDirectory = "."
                        .Save
                        End With
                        Attached Files
                        Last edited by Shazam; 6th June 2014, 04:24.

                        Comment


                        • #13
                          Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                          Originally posted by Shazam View Post
                          Is this what you meant copy the lines from my file 11 to 15?
                          Almost, you pasted 8 lines instead of 5. I still can't be sure what in your file is the 4th character on line 13.


                          If I copy the code from my previous post, I get that message too about unicode, but the scripts does run. I just have pasted the code again in my previous post, noe I don't get the message about unicode. Can you try again to copy-past the code in a new notepad file.

                          /Rems

                          This posting is provided "AS IS" with no warranties, and confers no rights.

                          __________________

                          ** Remember to give credit where credit's due **
                          and leave Reputation Points for meaningful posts

                          Comment


                          • #14
                            Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                            Hi,

                            I'm not getting the unicode message anymore but I'm still getting the same error when running your code. I copied your code again paste in notepad, ran it and still same error. Here's the code.

                            I ran this code on 3 different computers. I ran it on Windows 8.1 Pro 64-bit, Windows 7 Pro 64-bit and Server 2008 R2 Standard. All came back with the same error.


                            Code:
                            Set WshShell = CreateObject("WScript.Shell")
                            
                            strTartgetFile = "\\files\DATA\HR\Phone List\PhoneList\PHONELST.pdf"
                            
                            strAPP = GetProgramAssocWith("PDF")
                            
                            ShortcutName = "PHONELST"
                            ShortcutFolder = WshShell.SpecialFolders.Item("Desktop")
                            
                            ShortcutFile = ShortcutFolder & "\" & ShortcutName & ".lnk"
                            
                            With WshShell.CreateShortcut(ShortcutFile)
                               .TargetPath = strAPP
                               .Arguments = """" & strTartgetFile & """"
                               .WorkingDirectory = "."
                               .Save
                            End With
                            
                            PinToTaskbar
                            
                            wscript.quit
                            
                            Function GetProgramAssocWith(strExt)
                               Const HKCR=&H80000000
                               Set objReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
                            
                               strExt = Replace(strExt,"*","")
                               If Left(strExt,1) <> "." Then strExt = "." & strExt
                            
                               objReg.GetExpandedStringValue HKCR, strExt, strEntry, strType
                               strPath = strType & "\shell\open\command"
                               objReg.GetExpandedStringValue HKCR, strPath, strEntry, strValue
                            
                               'http://www.akaplan.com/blog/2010/12/vbscript-to-get-program-associated-with-file-extension/
                               If InStr(strValue,"rundll") Then
                            	Dim tArray
                            	tArray = split(strValue,",")
                            	GetProgramAssocWith = replace(tArray(0),"rundll32.exe","")
                               Else
                            	strValue = LCase(strValue)
                            	GetProgramAssocWith = Left(strValue,instrrev(strValue,".exe")+3)
                               End If
                            End Function
                            
                            Sub PinToTaskbar
                               'http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx
                               Set objShell = CreateObject("Shell.Application") 
                               Set objFolder = objShell.Namespace(ShortcutFolder)
                               Set objFolderItem = objFolder.ParseName(ShortcutFile)
                               Set colVerbs = objFolderItem.Verbs 
                               For Each objVerb in colVerbs
                                  Select Case Replace(objVerb.name, "&", "")
                                    case "Unpin from Taskbar" objVerb.DoIt
                                    'you can add other languages ??that apply to your environment....
                                  End Select
                               Next
                               Set colVerbs = objFolderItem.Verbs
                               For Each objVerb in colVerbs
                                  Select Case Replace(objVerb.name, "&", "")
                                    case "Pin to Taskbar" objVerb.DoIt
                                    case "Ajouter au menu Démarrer" objVerb.DoIt
                                    case "Aggiungi a menu Start" objVerb.DoIt
                                    case "An Startmenü anheften" objVerb.DoIt
                                    case "Aan het menu Start vastmaken" objVerb.DoIt
                                    case "Associar ao Menu Iniciar" objVerb.DoIt
                                    case "Anclar al menú Inicio" objVerb.DoIt
                                  End Select
                               Next
                            End Sub
                            Last edited by Shazam; 6th June 2014, 13:38.

                            Comment


                            • #15
                              Re: Pinning a specific shortcut file (*.lnk) onto the Windows 7 Taskbar?

                              How about this...

                              Can you upload the code as an attachment?

                              I'm thinking (this is a wild guess) that pasting your code to this forum might change unforeseen characters on your code. Wrapping the code on this thread might be causing the issue.

                              Comment

                              Working...
                              X