0
A while back I posted a question asking for a VB script to delete a shortcut "TeamViewer 12 Host" from anyone's and everyone's desktop if it existed. Local not remote. I ran it on my Windows 10 workstation and it worked. It even compensated for my desktop being redirected to a server. The problem is I can't get it to work on anyone else's computer. On everyone else's, even though they are local administrators, they get an Access Denied error when it tries to delete it. They too are local administrators. I have even tried running it from an elevated command prompt. No joy. The odd thing is that I can navigate to it via File Explorer and delete it no problem. Only think I can think is that it is something in the script. Any idea what is going on?
' Specify filename to remove from user desktops
strShortcut = "TeamViewer 12 Host.lnk"
' Create file system object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
' Find root of user data folder (C:\USERS on recent versions of Windows)
strUsers = objFSO.GetParentFolderName(objFSO.GetParentFolderName(objShell.SpecialFolders("Desktop")))
Set objUsers = objFSO.GetFolder(strUsers)
' Check each user folder, and look for our file in the DESKTOP subfolder
For Each objFolder In objUsers.SubFolders
strCheck = objFolder & "\Desktop\" & strShortcut
Wscript.Echo "Checking:" & strCheck
' If shortcut file exists remove it
If objFSO.FileExists(strCheck) Then
Wscript.Echo "Deleting:" & strCheck
objFSO.DeleteFile(strCheck)
End If
Next
does it help to add
on error resume next
to the start of the script? – HelpingHand – 2017-03-16T21:06:50.213