Page 1 of 1 1
Topic Options
#201407 - 2011-01-17 11:36 PM UnPinning Items from 2008 R2 Taskbar
sb1920alk Offline
Fresh Scripter

Registered: 2010-07-08
Posts: 15
Loc: USA
I have an issue while attempting to unpin items from the taskbar on 2008 R2 servers. I believe the issue is related to the kix executable running as a 32-bit process. An "identical" script in vbscript works successfully when run as a 64-bit process, but not as a 32-bit process. If I echo all of the "verbs" available, "Pin to Taskbar" is available instead of "Unpin from Taskbar." This is true for either script running in 32 bits. Only when the vbscript is run in 64 bits is the "verb" to unpin available.

Here are some examples trying to unpin powershell. The kix version does not work (due to the "verb" "Unpin from Taskbar" not being there), and if I call the vbscript from kix (making it run in 32-bits) the result is exactly the same. Running the vbscript natively works fine (in 64-bits).

In Kix:
 Code:
$objApp = CreateObject("Shell.Application")
$objFSO = CreateObject("Scripting.FileSystemObject")
 
UnPin("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe")
 
;************************Start of UnPin()
Function UnPin($SourceFileNameAndPath)
	;Unpins from the taskbar the program who's sources is provided
	;Syntax:	UnPin(<full path of shortcut's target>)
	;Example:	UnPin("C:\Windows\explorer.exe") ;Unpin explorer from the taskbar
	$ParentFolder = Left($SourceFileNameAndPath,InStrRev($SourceFileNameAndPath,"\") - 1)
	$Filename = Right($SourceFileNameAndPath,Len($SourceFileNameAndPath) - InStrRev($SourceFileNameAndPath,"\"))
	If $objFSO.FileExists($SourceFileNameAndPath)
	    $objFolder = $objApp.Namespace($ParentFolder)
	    $objFolderItem = $objFolder.ParseName($Filename)
	    $colVerbs = $objFolderItem.Verbs
	    For Each $objVerb in $colVerbs
		If Replace($objVerb.name,"&","") = "Unpin from Taskbar"
			$objVerb.DoIt
		EndIf
	    Next
	EndIf
EndFunction;<==UnPin()
;************************End of UnPin()


In vbscript:
 Code:
Public objApp, objFSO
Set objApp = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
UnPin("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe")

'************************Start of UnPin()
Function UnPin(SourceFileNameAndPath)
	'Unpins from the taskbar the program who's sources is provided
	'Syntax:	UnPin(<full path of shortcut's target>)
	'Example:	UnPin("C:\Windows\explorer.exe") 'Unpin explorer from the taskbar
	ParentFolder = Left(SourceFileNameAndPath,InStrRev(SourceFileNameAndPath,"\") - 1)
	Filename = Right(SourceFileNameAndPath,Len(SourceFileNameAndPath) - InStrRev(SourceFileNameAndPath,"\"))
	If objFSO.FileExists(SourceFileNameAndPath) Then
	    Set objFolder = objApp.Namespace(ParentFolder)
	    Set objFolderItem = objFolder.ParseName(Filename)
	    Set colVerbs = objFolderItem.Verbs
	    For Each objVerb in colVerbs
		If Replace(objVerb.name,"&","") = "Unpin from Taskbar" Then
			objVerb.DoIt
		End If
	    Next
	End If
End Function'<==UnPin()
'************************End of UnPin()

Top
#201408 - 2011-01-18 12:44 AM Re: UnPinning Items from 2008 R2 Taskbar [Re: sb1920alk]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Well you may be having an issue with this line...

If Replace(objVerb.name,"&","") = "Unpin from Taskbar"

I dont recall a builtin Replace function in kix.

*** Scratch that, I was looking at an old user manual.


Edited by CitrixMan (2011-01-18 12:47 AM)

Top
#201409 - 2011-01-18 01:05 AM Re: UnPinning Items from 2008 R2 Taskbar [Re: ShaneEP]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Try switching the WOW64 redirection.
Top
#201411 - 2011-01-18 08:46 AM Re: UnPinning Items from 2008 R2 Taskbar [Re: Arend_]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
I've been meaning to do this for months now... thanks for reminding me. I did not try your code above, but I am surprised it works at all using the path of the exe and not the link itself. Interesting none the less.


This hasn't been tested a lot, but worked in my initial tests on a Win 7 x64. If it doesn't work, it's possible I have the @producttype wrong. I do not have any R2 servers to test on. So let me know.

UnPinFrom() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=201410&Main=27133#Post201410

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

Top
#201412 - 2011-01-18 09:49 AM Re: UnPinning Items from 2008 R2 Taskbar [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
By the way... I learned this tonight... 2008 Server supports Vista Aero theme, and 2008 R2 supports Win 7 Aero theme/taskbar...

http://www.technospot.net/blogs/how-to-enable-aero-themes-in-windows-server-2008-r2/

Top
#201416 - 2011-01-18 09:27 PM Re: UnPinning Items from 2008 R2 Taskbar [Re: Allen]
sb1920alk Offline
Fresh Scripter

Registered: 2010-07-08
Posts: 15
Loc: USA
 Originally Posted By: Allen
...I am surprised it works at all using the path of the exe and not the link itself.

That is interesting, I didn't think of using the shortcut. Using vbscript anywhere, or using kixtart on 32-bit servers, I've had no issues with the samples I posted above.

 Originally Posted By: Allen
This hasn't been tested a lot, but worked in my initial tests on a Win 7 x64. If it doesn't work, it's possible I have the @producttype wrong. I do not have any R2 servers to test on. So let me know.

UnPinFrom() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=201410&Main=27133#Post201410

FYI, @ProductType returns "Windows Server 2008 R2 Enterprise Edition" in my case, so your syntax is ok there.

After thinking about this a little more, I like the idea of unpinning from the start menu and including .lnk in the shortcut name as options. Languages other than English are not an issue for me.

Here's what I'm using with those changes considered:
 Code:
$objApp = CreateObject("Shell.Application")
$objFSO = CreateObject("Scripting.FileSystemObject")

UnPin("Windows PowerShell","Taskbar") ;Unpin PowerShell from the taskbar

;************************Start of UnPin()
Function UnPin($ShortcutName,$StartMenuOrTaskbar)
	;Unpins from the start menu or taskbar the program who's shortcut name is provided
	;Syntax:	UnPin(<shortcut name>,<"Start Menu" | "Taskbar">)
	;Example:	UnPin("Windows PowerShell","Taskbar") ;Unpin PowerShell from the taskbar
	If $StartMenuOrTaskbar = "Start Menu"
		$ShortcutPath = %AppData% + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu"
		$Verb = "Unpin from Start Menu"
	EndIf
	If $StartMenuOrTaskbar = "Taskbar"
		$ShortcutPath = %AppData% + "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
		$Verb = "Unpin from Taskbar"
	EndIf
	If LCase(Right($ShortcutName,4)) <> ".lnk"
		$ShortcutName = $ShortcutName + ".lnk"
	EndIf
	If $objFSO.FileExists($ShortcutPath + "\" + $ShortcutName)
	    $objFolder = $objApp.Namespace($ShortcutPath)
	    $objFolderItem = $objFolder.ParseName($ShortcutName)
	    $colVerbs = $objFolderItem.Verbs
	    For Each $objVerb in $colVerbs
		If Replace($objVerb.name,"&","") = $Verb
			$objVerb.DoIt
		EndIf
	    Next
	EndIf
EndFunction;<==UnPin()
;************************End of UnPin()


Thanks,

Top
#201417 - 2011-01-18 09:29 PM Re: UnPinning Items from 2008 R2 Taskbar [Re: Arend_]
sb1920alk Offline
Fresh Scripter

Registered: 2010-07-08
Posts: 15
Loc: USA
 Originally Posted By: apronk
Try switching the WOW64 redirection.

This may be a good option, but I didn't have any more time to spend on this issue. It would be interesting to know why the list of verbs is different depending on the bit depth of the script process.

Top
#201418 - 2011-01-19 12:28 AM Re: UnPinning Items from 2008 R2 Taskbar [Re: sb1920alk]
sb1920alk Offline
Fresh Scripter

Registered: 2010-07-08
Posts: 15
Loc: USA
I'm still having an issue trying to unpin Server Manager from the taskbar. @Error and @Serror give: -2147352567 COM exception error "DoIt" ((null) - (null)) [-2147352567/80020009] using my kix script or Allen's UDF (no issues with vbscript).

Additionally, Windows prompts: Problem with Shortcut. The item 'ServerManager.msc' that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly. Do you want to delete this shortcut?

Clicking No results in no change. Clicking Yes deletes the shortcut in %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar, but the icon pinned to the taskbar remains. Logging off and on changes the icon to a blank icon that doesn't work, but is still pinned.

Top
#201424 - 2011-01-19 05:17 PM Re: UnPinning Items from 2008 R2 Taskbar [Re: sb1920alk]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Maybe that shortcut is set as a system file. Go to that directory and check it's attributes.
Top
#203777 - 2011-11-17 05:00 PM Re: UnPinning Items from 2008 R2 Taskbar [Re: Allen]
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
On a Windows 7 (32-bit) machine, when I remove an item from the Taskbar, it appears as a Recent item on the Start Menu. Is there a way to prevent this from happening? ... or more importantly, is anyone else seeing this behavior?

Edited by JNK (2011-11-17 05:01 PM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1324 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.146 seconds in which 0.11 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org