Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Need help with a script to remove media player icon from the desktop

Posted on 2007-10-19
Medium Priority
Last Modified: 2012-05-05
I need assistance in writing a script that will remove windows media player shortcut from the desktop. I found this script but it doesn't seem to work.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_ShortcutFile Where FileName = 'Windows Media Player'")

For Each objItem in colItems
    If Instr(objItem.Name, "desktop") Then
        strPath = objItem.Name
        strPath = Replace(strPath, "\", "\\")
        Set colFiles = objWMIService.ExecQuery _
            ("Select * From CIM_Datafile Where Name = '" & strpath & "'")
        For Each objFile in colFiles
    End If
Question by:USBMHC

Expert Comment

ID: 20111080
Where FileName = 'Windows Media Player'")

Is that what you actually have in the script?  I don't think the FileName for the Shortcut is going to be "Windows Media Player"

Expert Comment

ID: 20111186
Depending on the version of Windows.  It should be the full path.

XP:  C:\Documents and Settings\All Users\Desktop\
Vista:  C:\Users\Public\Public Desktop\

Expert Comment

ID: 20111287
the path is empty, the condition on Instr(objItem.Name, "Desktop") is returning false.
LVL 24

Accepted Solution

Kenneniah earned 2000 total points
ID: 20111460
Just an FYI you can also use group policy.
Computer Configuration|Administrative Templates|Windows Components|Windows Media Player "Prevent Desktop Shortcut Creation".

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
It is a real story and is one of my scariest tech experiences. Most users think that IT experts like us know how to fix all computer problems. However, if there is a time constraint and you MUST not fail the task or you will lose your job, a simple …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question