Jump to content

Autoit to unpin icons on taskbar


tcox8
 Share

Recommended Posts

Hello all,

I'm having a problem trying to use COM to remove the icons from the taskbar (unpin from taskbar) in Windows 7. Here is the source of the .vbs script I have found online that does the same thing:

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

'''''''''''''''''''''''''''''''''''''''Unpin Shortcuts'''''''''''''''''''''''''''''''''''''''
'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If

Here is what I have so far. Using the error handler out of the AutoIt help file I know that I am not receiving any COM errors, but nothing seems to happen after running this:

$UsrProf = @AppdataDir & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
$Shell = ObjCreate("shell.application") ;Let's get the Windows Shell Object
If FileExists($UsrProf & "\Windows Explorer.lnk") Then
    $objFolder = $Shell.Namespace(@StartMenuDir & "\Programs\Accessories")
    $objFolderItem = $objFolder.ParseName("Windows Explorer.lnk")
    $objFolderItem.InvokeVerb("Unpin from Taskbar")
    if $g_eventerror then Msgbox(0,"","the previous line got an error.") ;This goes to the AutoIt help file error handler
EndIf

"There are only 10 types of people in the world: Those who understand binary, and those who don't"

Link to comment
Share on other sites

I just found an easier way to unpin the icons from the desktop by running these simple commands:

RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband","Favorites","REG_BINARY","0xFF")
RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband","FavoritesResolve")

processclose("explorer.exe")
Edited by tcox8

"There are only 10 types of people in the world: Those who understand binary, and those who don't"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...