Windows 8 and 8.1 Forums


Pin to Taskbar with VB Script

  1. #1


    Posts : 2
    Windows 8

    Pin to Taskbar with VB Script


    Hello

    Is it still possible to use the VB script in Windows 8 that many of us used to pin programs and shortcuts in Windows 7. I just have a couple items I would like to have pinned on users desktop taskbars and the script below worked perfect in Windows 7. I tried it today and nothing gets pinned but it still deletes itself. Any ideas? I did verify I had the .lnk in the locations below.

    Thank you!


    Code:
    Option Explicit
    
    
    Const CSIDL_COMMON_PROGRAMS = &H17
    Const CSIDL_PROGRAMS = &H2
    Const CSIDL_STARTMENU = &HB
    
    
    Dim objShell, objFSO
    Dim objCurrentUserStartFolder
    Dim strCurrentUserStartFolderPath
    Dim objAllUsersProgramsFolder
    Dim strAllUsersProgramsPath
    Dim objFolder
    Dim objFolderItem
    Dim colVerbs
    Dim objVerb
    
    
    Set objShell = CreateObject("Shell.Application")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
    strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
    Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
    strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
    
    
    ' - Pin to Taskbar -
    
    
    'Microsoft Outlook 2013
    If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office 2013\Outlook 2013.lnk") Then
        Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office 2013")
        Set objFolderItem = objFolder.ParseName("Outlook 2013.lnk")
        Set colVerbs = objFolderItem.Verbs
        For Each objVerb in colVerbs
            If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
        Next
    End If
    
    'Snipping Tool
    If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Snipping Tool.lnk") Then
        Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
        Set objFolderItem = objFolder.ParseName("Snipping Tool.lnk")
        Set colVerbs = objFolderItem.Verbs
        For Each objVerb in colVerbs
            If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
        Next
    End If
    
    'Delete the script
    DeleteSelf
    
    
    Sub DeleteSelf()       
            Dim objFSO
            'Create a File System Object
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            'Delete the currently executing script
            objFSO.DeleteFile WScript.ScriptFullName
            Set objFSO = Nothing
    End Sub
    Last edited by Brink; 30 Dec 2012 at 19:25. Reason: code box

      My System SpecsSystem Spec

  2. #2


    Posts : 22,582
    64-bit Windows 10


    Hello ws2000, and welcome to Eight Forums.

    You might see if this may be able to work for you instead.

    Taskbar Pinned Apps - Back Up and Restore in Windows 8

    Hope this helps,
    Shawn
      My System SpecsSystem Spec

  3. #3


    Posts : 2
    Windows 8


    Its working again now. A couple mistakes and in my profile C:\Users\Me\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\ the Accessories folder is displayed as Windows Accessories but is still just Accessories for scripting. I fixed the script above. Hopefully it saves someone the hour I lost.

    Thanks.
      My System SpecsSystem Spec

  4. #4


    Posts : 22,582
    64-bit Windows 10


    Great news.
      My System SpecsSystem Spec

Pin to Taskbar with VB Script
Related Threads
Hey guys. just finished formating my computer (using the built in windows 8 feature). once it was up and running i uninstalled all the built in stuff lenovo brings with the computer using revo uninstaller. in the procces i also removed all registry and files those programs left.. but now theres...
Unresponsive Script in General Support
I keep getting this message. 38045 It's very annoying, and it REALLY slows down my machine. Sometime s it won't respond, iterally, for like 10 minutes. How can I solve this problem permanently? Thanks everyone!
VB Script not working in General Support
Hello: I am knew in this forum. I have just bought Dell XPS 12 Duo with Windows 8. I was used to working with Windows 7 and i have few VBS script which worked just fine in Windows 7. Now the same script would not work on Windows 8. I would appreciate if someone can help me resolve the...
I'm looking to remap the vol+, and vol- buttons to run a simple script instead of adjusting the volume on the computer. Anyone have any ideas?
Script Errors in General Support
I use W8 Pro and this week I started to receive many different types of script errors on the MSN homepage and several other websites Ideas please on how to correct the situation. Thanks
Script Error in Performance & Maintenance
I have no idea what happened but today I get a " Script Error " on every website and subsequent pages that I enter. Sorry I forgot how to make a copy of what appears on the screen. Thanks
VBS Script is limited in System Security
Using a tutorial yesterday, I couldn't use a lot of my commands I'd normally use in VBS. Security?
Eight Forums Android App Eight Forums IOS App Follow us on Facebook