Good morning, hopefully I have this in the correct topic!
I have a need to delete a specific URL shortcut that would be located on users desktops before copying out a new shortcut to the 'All Users' desktop. I have found the vbscript code below to delete a .lnk from any of the user profiles \desktop folder on the PC which works perfectly. Unfortunately, it's a .url file that needs to be deleted instead. Does anyone know how to modify the script below or have something else that would do the trick????
____________________________________________________________
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_ShortcutFile Where FileName = 'Name of shortcut to delete'")
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
objFile.Delete
Next
End If
Next
___________________________________________________________________________
Thanks!
SG