vbscript to unpin from task bar not working


  1. Posts : 2
    Windows 7 Professional x32 & x64
       #1

    vbscript to unpin from task bar not working


    Hi,

    I can't get this vbscript to work. Any ideas?

    Const CSIDL_COMMON_PROGRAMS = &H17
    Const CSIDL_PROGRAMS = &H2
    Const CSIDL_STARTMENU = &HB
    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

    If objFSO.FileExists(strAllUsersProgramsPath & "\Programs\Windows Media Player.lnk") Then
    Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
    Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
    Next
    End If

    If objFSO.FileExists(strAllUsersProgramsPath & "\Programs\Google Chrome\Google Chrome.lnk") Then
    Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
    Set objFolderItem = objFolder.ParseName("Google Chrome.lnk")
    Set colVerbs = objFolderItem.Verbs
    For Each objVerb in colVerbs
    If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt

    Next
    End If

    Thanks.
      My Computer


  2. Posts : 5,092
    Windows 7 32 bit
       #2

    "Can't get it to work" is kind of vague. Firstly when you create objects from ActiveX you should check the return to see if an object was indeed created. Using error checking will give more clues what went wrong than me guessing. :)

    If you get some error messages then post. But I think you'd have better luck on a vbs programming forum. Many more vbs aficionados would read it for one thing. :)
      My Computer


  3. Posts : 2
    Windows 7 Professional x32 & x64
    Thread Starter
       #3

    There were no error messages when it ran. Sorry for being vague.
      My Computer


  4. Posts : 5,092
    Windows 7 32 bit
       #4

    Briandr said:
    There were no error messages when it ran. Sorry for being vague.
    Always check return values unless you are just posting example code meant to be fleshed out by others and need to save space. That's what return values are for. So you have a clue what happened.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:37.
Find Us