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




