Kaseya Community

Need to remove a shortcut from Start Menus and Desktop

  • I'm looking for a script to remove a shortcut icon from all Start Menus and Desktops.  Specifically Windows XP, but if the same script could be used for Vista and 7 it would be handy.  The program, a network  install, has been removed but shortcuts on individual machines abound.  If no script exists good tips on how to build one would be appreciated.

  • Shortcuts are files just like any other. The extension you're looking for is LNK, so whatever your shortcut is it will appear as "<path>\<shortcut-name>.lnk"

    Another thing to be aware of is shortcut and desktop icons can exist in two places: the user's individual profile and the All Users profile.

    Hope this helps.

  • Yeah, that's kind of where I'm stuck.  The <path>.  We're a school district and computers are shared.  The part of the path with the username could be any of over 1000 usernames.  Some users may have never logged in on a specific machine, some may have logged in but not made the shortcut I am looking for, other have logged in and have made the shortcut.  Users run on the young side and teachers expect me to keep the desktops neat and clean.  In this case the program is gone, but the icon is still around in many cases (because the program didn't make the shortcut it didn't remove them when it was uninstalled).  Looking for a way to *search* the item whether it by in any or multiple user profiles in the Documents and Settings folder and then delete it if it is found.

  • You can search with DOS like this:

    dir <shortcut>.lnk /S /B

    If you want to take action on those files, you might be better served using FORFILES. Windows XP doesn't come with it by default, but you can kick it down to the remote computer with Kaseya. Your command might look something like this:

    forfiles -s -m shortcutName.lnk -c "cmd /C del @path /S /F /Q"

  • Cool.  That looks like a plan.  Thanks.