Windows 7 Scripting Question, add and remove items from the taskbar at log in.

Hello All,
First I admit I am inept at code and scripting.

I have copeid and hacked most of this code from other support sites (all free and legit), but cannot get it all to work.

My goal is the following; modify the suers taskbar by removine Windows Explorer and Media Player and add Microsft Word and Microsoft Excel.

When a user logs into the computer, the following script is run.
'********************************************************************************************
 '* *
 '* PIN TO TASKBAR SCRIPT *
 '* Dan M - 07/29/2010 *
 '* *
 '********************************************************************************************
 on error resume next
 'Required Objects
 Set objShell = CreateObject("Shell.Application")
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 

'Remove Pins
 strlPath = "C:\Program Files (x86)\Windows Media Player\wmplayer.exe"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next
 
'Remove Pins
 strlPath = "C:\Windows\explorer.exe"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next
 

'Pin Office Objects
 strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
 Next
 
strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
 Next
 
'strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE"
' strFolder = objFSO.GetParentFolderName(strlPath)
' strFile = objFSO.GetFileName(strlPath)
' Set objFolder = objShell.Namespace(strFolder)
' set objFolderItem = objFolder.ParseName(strFile)
' Set colVerbs = objFolderItem.Verbs
' For each itemverb in objFolderItem.verbs
' If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
' Next



The script is set to run from the users profile, as specified on the 2008 R2 Server, in the Profile tab, under Scripts. The file is located in the netlogon folder and the users group has permission to read and excute the script.

The script should remove the Windows Media Player and Windows Explorer icon from the taskbar.
It should then add the Miscrosoft Word and Microsoft Excel icon to the taskbar.

Each user I test, the script runs and adds the Word and Excel file, but does not remove the Windows Media Player file.

Ay ideas as to why? And how do I fix it?

Thank you.
alanseanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

marek1712Commented:
A quick script made with PowerShell:
 
$path='C:\Program Files (x86)\Microsoft Office\Office14\'
$location=$env:APPDATA+'\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar'
Remove-Item "$location\Windows Media Player.lnk"
Remove-Item "$location\*Explorer*.lnk"
$scut = New-Object -ComObject Wscript.Shell
$lnk = $scut.CreateShortcut($location+".\Word.lnk")
$lnk.TargetPath=$path+'Winword.exe'
$lnk.Save()
$lnk = $scut.CreateShortcut($location+".\Excel.lnk")
$lnk.TargetPath=$path+'Excel.exe'
$lnk.Save()

Open in new window

You'll have to modify the PATH variable to suit your version of Office and Windows (x86 vs x64). Didn't bother to make it automatic. I can do it of course later.
Since you're using W7/W2008 - you can save it as .ps1 file and run as a logon script via GPO. Just make sure to alter the Set-ExecutionPolicy to make executing PoSh scripts possible (doable via GPO - Google for it).
Next step. Unfortunately you'll have to make these changes by yourself on one computer, export the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband
and then import it on every computer (with i.e. GPP). It will OVERWRITE users' pinned programs though.
alanseanAuthor Commented:
marek1712,

Thanks for the PowerShell script, but this is why I wanted to do it witha  VB script. It is not proactical to make the change to each computer by exporting and importing the registry key for each user.

That is if I understand your two step solution correctly.
marek1712Commented:
Unfortunately - I won't be able to help you with VBS ;)
As for this reg key. No, it's necessary to export it only on one computer - the one with the items you need already in place. And then, by using Group Policy Preferences, distribute it for others...
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

matrixnzCommented:
Have you got the correct wmplayer.exe?

Add both C:\Program Files\Windows Media Player\wmplayer.exe as well as C:\Program Files (x86)\Windows Media Player\wmplayer.exe

Also if you want to stop these from creating in the firstplace you need to either rename the stubpath to hidestubpath (can be anything but stubpath) or delete it altogether.

The StubPath value is found under Active Setup in HKLM see Windows Media Player keys below.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{6BF52A52-394A-11d3-B153-00C04F79FAA6}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\>{22d6f312-b0f6-11d0-94ab-0080c74c7e95}

Cheers
Run5kCommented:
A few months ago, RobSampson (the EE community's top-ranked VB Script expert) addressed similar questions in a pair of discussions.  Hopefully his feedback will be beneficial to you, too:

http://www.experts-exchange.com/Q_27406005.html

http://www.experts-exchange.com/Q_27417621.html
alanseanAuthor Commented:
matrixnz and Run5k,

Thank you both for hte suggestions, I will give them both a try in the next few hours.

I did not even think about the dual file locations for WMPlayer.
RobSampsonCommented:
Hi, the code in the second link that Run5K provided will allow to pin and unpin items, but only in separate runs.  I could modify it so that you specify a mode for each item in the array if that would make things easier?

Regards,

Rob.
alanseanAuthor Commented:
@ RObSampson  - That would be fantastic. Thank you. - Alan
RobSampsonCommented:
OK, try this.

You can see if the array you specify "pin" or "unpin" and the next element is the file name you want to link to.

You specify "Taskbar" or "Start Menu" as strLocation, and it should work.

Regards,

Rob.
' Specify the file paths of the file to pin or unpin
' If strMode = "unpin", you can use specify "*" in the array to unpin all items from the Taskbar or Start Menu.
'strMode can be "Pin" or "Unpin"
arrFileNames = Array( _
	"pin", "C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE", _
	"unpin", "C:\Program Files\Microsoft Office 2007\Office12\EXCEL.EXE", _
	"unpin", "C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE" _
	)

'strLocation can be "Start Menu" or "Taskbar"
strLocation = "Taskbar"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShellApp = CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
If LCase(strLocation) <> "start menu" And LCase(strLocation) <> "taskbar" Then
	WScript.Echo "Location is incorrect. Please set to ""Start Menu"" or ""Taskbar""."
Else
	For intItem = 0 To UBound(arrFileNames) - 1 Step 2
		strMode = LCase(arrFileNames(intItem))
		strFilePath = arrFileNames(intItem + 1)
		If strMode = "pin" Then
			strVerb = LCase(strMode & " to " & strLocation)
			strMessage = " has been " & strMode & "ned to the " & strLocation & "."
		ElseIf strMode = "unpin" Then
			strVerb = LCase(strMode & " from " & strLocation)
			strMessage = " has been " & strMode & "ned from the " & strLocation & "."
		End If
		If LCase(strFilePath) = "*" And strMode = "unpin" Then
			strTaskBar = objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\" & Replace(strLocation, " ", "") & "\"
			For Each objFile In objFSO.GetFolder(strTaskBar).Files
				If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
					objVerb.DoIt
					WScript.Echo strFilePath & strMessage
				End If
			Next
		Else
			If objFSO.FileExists(strFilePath) = True Then
				Set objFile = objFSO.GetFile(strFilePath)
				Set objFolder = objShellApp.Namespace(objFile.ParentFolder & "\")
				Set objFolderItem = objFolder.ParseName(objFile.Name)
				Set colVerbs = objFolderItem.Verbs
				blnOptionFound = False
				For Each objVerb In colVerbs
					If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
						objVerb.DoIt
						blnOptionFound = True
					End If
				Next
				If blnOptionFound = True Then
					WScript.Echo strFilePath & strMessage
				Else
					WScript.Echo "Unable to " & strMode & " " & strFilePath & ". The verb does not exist."
				End If
			Else
				WScript.Echo "Could not find " & strFilePath
			End If
		End If
	Next
End If

Open in new window

alanseanAuthor Commented:
Ugg.

Still not working. The Windows Media Player is still there. Even though the Explorer is removed and Word and Excel are added.

I have added three paths to remove windows Media Player. The first path I copied from the actual icon on the start menu.

"%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe /prefetch:1"
C:\Program Files\Windows Media Player\wmplayer.exe
C:\Program Files (x86)\Windows Media Player\wmplayer.exe


Here is the script. I have it saved as clearandaddtotaskbar.vbs:

'********************************************************************************************
 '* *
 '* PIN TO TASKBAR SCRIPT *
 '* Dan M - 07/29/2010 *
 '* *
 '********************************************************************************************
 on error resume next
 'Required Objects
 Set objShell = CreateObject("Shell.Application")
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 

'Remove Pins
 strlPath = "C:\Program Files\Windows Media Player\wmplayer.exe"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next

'Remove Pins
 strlPath = "%programFiles(x86)\Windows Media Player\wmplayer.exe /prefetch:1"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next
 
'Remove Pins
 strlPath = "C:\Program Files (x86)\Windows Media Player\wmplayer.exe"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next


'Remove Pins
 strlPath = "C:\Windows\explorer.exe"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Unpin from Taskbar" Then itemverb.DoIt
 Next
 

'Pin Office Objects
 strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
 Next
 
strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"
 strFolder = objFSO.GetParentFolderName(strlPath)
 strFile = objFSO.GetFileName(strlPath)
 Set objFolder = objShell.Namespace(strFolder)
 set objFolderItem = objFolder.ParseName(strFile)
 Set colVerbs = objFolderItem.Verbs
 For each itemverb in objFolderItem.verbs
 If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
 Next
 
'strlPath = "C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE"
' strFolder = objFSO.GetParentFolderName(strlPath)
' strFile = objFSO.GetFileName(strlPath)
' Set objFolder = objShell.Namespace(strFolder)
' set objFolderItem = objFolder.ParseName(strFile)
' Set colVerbs = objFolderItem.Verbs
' For each itemverb in objFolderItem.verbs
' If Replace(itemverb.name, "&", "") = "Pin to Taskbar" Then itemverb.DoIt
' Next


alanseanAuthor Commented:
@RobSampson - Do I need to make changes to the code? If I run your code as it is now, I just get a DOS window that runs continually.
RobSampsonCommented:
You don't need to use your version of the code at all.  Use the code I post below only.

I have added "pin" elements for word and excel, and "unpin" elements for windows explorer and media player.  I have tested it on my system, and it works fine.

Copy the code below into Notepad, save it as ModifyTaskbar.vbs or something, and run it.

If you don't want the messages that tell you what is happening, comment out the WScript.Echo statements for the relevant messages.

Regards,

Rob.
' Specify the file paths of the file to pin or unpin
' If strMode = "unpin", you can use specify "*" in the array to unpin all items from the Taskbar or Start Menu.
'strMode can be "Pin" or "Unpin"
arrFileNames = Array( _
	"pin", "C:\Program Files\Microsoft Office 2007\Office12\WINWORD.EXE", _
	"pin", "C:\Program Files\Microsoft Office 2007\Office12\EXCEL.EXE", _
	"unpin", "C:\Program Files\Windows Media Player\wmplayer.exe", _
	"unpin", "C:\Windows\explorer.exe" _
	)

'strLocation can be "Start Menu" or "Taskbar"
strLocation = "Taskbar"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShellApp = CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
If LCase(strLocation) <> "start menu" And LCase(strLocation) <> "taskbar" Then
	WScript.Echo "Location is incorrect. Please set to ""Start Menu"" or ""Taskbar""."
Else
	For intItem = 0 To UBound(arrFileNames) - 1 Step 2
		strMode = LCase(arrFileNames(intItem))
		strFilePath = arrFileNames(intItem + 1)
		If strMode = "pin" Then
			strVerb = LCase(strMode & " to " & strLocation)
			strMessage = " has been " & strMode & "ned to the " & strLocation & "."
		ElseIf strMode = "unpin" Then
			strVerb = LCase(strMode & " from " & strLocation)
			strMessage = " has been " & strMode & "ned from the " & strLocation & "."
		End If
		If LCase(strFilePath) = "*" And strMode = "unpin" Then
			strTaskBar = objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\" & Replace(strLocation, " ", "") & "\"
			For Each objFile In objFSO.GetFolder(strTaskBar).Files
				If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
					objVerb.DoIt
					WScript.Echo strFilePath & strMessage
				End If
			Next
		Else
			If objFSO.FileExists(strFilePath) = True Then
				Set objFile = objFSO.GetFile(strFilePath)
				Set objFolder = objShellApp.Namespace(objFile.ParentFolder & "\")
				Set objFolderItem = objFolder.ParseName(objFile.Name)
				Set colVerbs = objFolderItem.Verbs
				blnOptionFound = False
				For Each objVerb In colVerbs
					If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
						objVerb.DoIt
						blnOptionFound = True
					End If
				Next
				If blnOptionFound = True Then
					WScript.Echo strFilePath & strMessage
				Else
					WScript.Echo "Unable to " & strMode & " " & strFilePath & ". The verb does not exist."
				End If
			Else
				WScript.Echo "Could not find " & strFilePath
			End If
		End If
	Next
End If

Open in new window

alanseanAuthor Commented:
@RobSampson - Ok,will give it a try on Tuesday. Thanks you.
alanseanAuthor Commented:
Still not working.

I modified the code to add evey WMPlayer.exe file I could find on the system.

The Excel and Word shortcuts add just fine and the Explorer is unpinned, yet Winodws Media Player is still there.

If I right click on the WMP icon on the taskbar, then Right Click on Windows Media Player and choose Properties, the Start in: path = is "%ProgramFiles(x86)\Windows Media Player", the Taget = "%ProgramFiles(x86)\Windows Media Player\Windows Media Player\wmplayer.exe" /prefetch:1.

This is my modified code running as a vbs script at user login.

' Specify the file paths of the file to pin or unpin
' If strMode = "unpin", you can use specify "*" in the array to unpin all items from the Taskbar or Start Menu.
'strMode can be "Pin" or "Unpin"
arrFileNames = Array( _
      "pin", "C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE", _
      "pin", "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE", _
      "unpin", "C:\Windows\winsxs\wow64_microsoft-windows-mediaplayer-core_31bf3856ad364e35_6.1.7601.17514_none_73e472e09a1a05d1\wmplayer.exe", _
                     "unpin", "C:\Program Files\Windows Media Player\wmplayer.exe", _
                     "unpin", "C:\Program Files (x86)\Windows Media Player\wmplayer.exe", _
      "unpin", "C:\Windows\explorer.exe" _
      )

'strLocation can be "Start Menu" or "Taskbar"
strLocation = "Taskbar"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShellApp = CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
If LCase(strLocation) <> "start menu" And LCase(strLocation) <> "taskbar" Then
      WScript.Echo "Location is incorrect. Please set to ""Start Menu"" or ""Taskbar""."
Else
      For intItem = 0 To UBound(arrFileNames) - 1 Step 2
            strMode = LCase(arrFileNames(intItem))
            strFilePath = arrFileNames(intItem + 1)
            If strMode = "pin" Then
                  strVerb = LCase(strMode & " to " & strLocation)
                  strMessage = " has been " & strMode & "ned to the " & strLocation & "."
            ElseIf strMode = "unpin" Then
                  strVerb = LCase(strMode & " from " & strLocation)
                  strMessage = " has been " & strMode & "ned from the " & strLocation & "."
            End If
            If LCase(strFilePath) = "*" And strMode = "unpin" Then
                  strTaskBar = objShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\" & Replace(strLocation, " ", "") & "\"
                  For Each objFile In objFSO.GetFolder(strTaskBar).Files
                        If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
                              objVerb.DoIt
                              WScript.Echo strFilePath & strMessage
                        End If
                  Next
            Else
                  If objFSO.FileExists(strFilePath) = True Then
                        Set objFile = objFSO.GetFile(strFilePath)
                        Set objFolder = objShellApp.Namespace(objFile.ParentFolder & "\")
                        Set objFolderItem = objFolder.ParseName(objFile.Name)
                        Set colVerbs = objFolderItem.Verbs
                        blnOptionFound = False
                        For Each objVerb In colVerbs
                              If LCase(Replace(objVerb.name, "&", "")) = strVerb Then
                                    objVerb.DoIt
                                    blnOptionFound = True
                              End If
                        Next
                        If blnOptionFound = True Then
                              'WScript.Echo strFilePath & strMessage
                        Else
                              'WScript.Echo "Unable to " & strMode & " " & strFilePath & ". The verb does not exist."
                        End If
                  Else
                        'WScript.Echo "Could not find " & strFilePath
                  End If
            End If
      Next
End If

matrixnzCommented:
Question: When you right click the shortcut in taskbar is one of the options "Unpin from Taskbar"?  Also can you check what the file attributes of the shortcut are, read-only, system, etc...?
Open Command Prompt
Navigate to: %AppData%\QuickLaunch\User Pinned\Taskbar
Attrib "Windows Media Player.lnk"
(Can you post the results here?)

Have you tried right clicking the script and selecting "Run as Administrator", note: this maybe caused by the attributes on the shortcut so would suggest checking the attributes first.
alanseanAuthor Commented:
@matrixnz:

I am able to right click in the WMP shortcut on the taskbar. I have to options, "unpin this program from the taksbar: and the Windows Midea Player" icon. If I right click on the icon, the attributes are unchecked for Read-only and hidden. The Advanced button shows "File is ready for Archiving" and "allow this file to have contents indexed in addition to file properties"

As the Student user, I am unable to run the cmd prompt.

But if I log in as an Admin user, I get the following message when running your command prompt command. "The system cannot find the path specified". The path I typed in was at the C:\ prompt and I typed in %AppData%\QuickLaunch\User Pinned\Taskbar.
matrixnzCommented:
Sorry should of been:

%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned
alanseanAuthor Commented:
%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned  returns 'C:\Users\Username.cre******\AppData\Roaming\Microsoft\Internet' is not a recognized as an internal or external command, operable program or batch file.
matrixnzCommented:
Put between quotes "" i.e.
cd "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned"
alanseanAuthor Commented:
The result is :
A           C:\Users\Username.Cr######\AppData\Roaming\Microsoft\Internet Exploer\Quick Launch\User Pinned\Taskbar\Windows Media Player.lnk
matrixnzCommented:
That all appears to be normal, what happens if you run the script as Administrator? or just "Run as Administrator"
alanseanAuthor Commented:
THe script is run at log on as with System permissions.

If I log in as a student and run the vbs script as an ADministrator, the same thing happens, Explorer is unpinned, Word and Excel are pinned, yet WMP stays on the taskbar.
matrixnzCommented:
Little confused, because it shouldn't work at all for the other shortcuts, the reason being is that the taskbar settings are held in the logged on users registry, if you select RunAs not "Run as Administrator" (Windows 7) the script is running in the RunAs users context not the users, it's also the same when running under System.  Can you log on as an Administrator and run the script, can you run the script directly as yourself?
alanseanAuthor Commented:
I can run the script as myslef, when I log in as an administrator, I get the same result.

I am confused as well. Why won't this *&!$ file go away.
matrixnzCommented:
Maybe try the script, steps, manually:

Open Windows Explorer
Navigate to "C:\Program Files (x86)\Windows Media Player"
Right Click "wmplayer.exe"
Select "Unpin from taskbar"
Does the shortcut disappear?

RobSampsonCommented:
I hate to tell you this, but on my Windows 7 64 bit, this line works for me:
      "unpin", "C:\Program Files (x86)\Windows Media Player\wmplayer.exe", _

even when logged in as a user with only "user" privileges.

Logged in as a normal user, can you manually unpin it (I forgot if you've tested that already)?

You can pin it back again by clicking the Start button, then Programs, right clicking the Windows Media Player shortcut, and clicking Pin to Taskbar.

Rob.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobSampsonCommented:
Thanks for the grade....did you find out why it didn't work?  You did have that line in originally.....

Rob.
matrixnzCommented:
What a waste of time
alanseanAuthor Commented:
I did not find out why it did not work in the script. IT works manually, if I unpin the the shortcut by right clicking on it, but not if I run the script. I editied the code to be only the WMP lines and it still did not work.

I assume it is not the coed and something else that is preventing the program from being removed.
RobSampsonCommented:
OK.  Just one more thing I'd like you to clarify....when you browse to
C:\Program Files (x86)\Windows Media Player

and right click the
wmplayer.exe

file, is there an option that says *exactly*
Unpin from Taskbar

If so, then I still have no idea why it wouldn't work, but if it doesn't say exactly that, then that could be the reason....

Rob.
alanseanAuthor Commented:
Yes,

OK.  Just one more thing I'd like you to clarify....when you browse to
C:\Program Files (x86)\Windows Media Player

and right click the
wmplayer.exe

file, is there an option that says *exactly*
Unpin from Taskbar


It appears and works from there.

Again the issue is the script does not work.

I am assuming it is another issue.
RobSampsonCommented:
That's a shame.  I can't say, then, why it doesn't work.  I can't replicate the issue.

Sorry.

Rob.
alanseanAuthor Commented:
No worries.

Everything else works.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.