Desktop Icon Search

Comments

5 comments

  • Gary White

    We have a package that removed desktop shortcuts from all profiles. Our case might be a little different from yours in that our shortcuts were url shortcuts to a web based timekeeping system so they ended in .url instead of .lnk, but that concept should be the same.

    In my case the PDQ package is just calling a batch file. The batch file then iterates through all profiles looking for the shortcuts. In my batch file there are three different shortcuts it's looking for. Here is the script from the batch file:

    for /f %%a in ('dir /B /AD C:\Users') do (
        if exist "C:\Users\%%a\Desktop\Kronos Workforce Central.url" del /F /Q "C:\Users\%%a\Desktop\Kronos Workforce Central.url"
        if exist "C:\Users\%%a\Desktop\Quick TimeStamp.url" del /F /Q "C:\Users\%%a\Desktop\Quick TimeStamp.url"
        if exist "C:\Users\%%a\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Quick TimeStamp.url" del /F /Q "C:\Users\%%a\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Quick TimeStamp.url"
    )

    Not sure about the name variations you mention, but if there's a commonality, hopefully you can wildcard it.

    1
    Comment actions Permalink
  • Heath Grim

    This is a Powershell script that I use to search for a shortcut and then delete it.  In this case, it is looking for an example.lnk file in desktop folder for each user's profile.

    Get-ChildItem C:\Users\*\Desktop\Example*.lnk | Remove-Item

    1
    Comment actions Permalink
  • Gary White

    That looks a lot easier than my script. I am learning more and more how much powershell can do, but am nowhere near fluent in it.

    0
    Comment actions Permalink
  • Dan Sadler

    Thanks Heath and Gary!  I think Heath's will work just fine. 

    0
    Comment actions Permalink
  • Craig Takahashi

    Thought I'd post a solution that worked for me with PDQ Inventory and Powershell. 

    Reference URL: http://keithbloom.blogspot.com/2009/06/powershell-delete-files-containing.html

    My goal was to search through all user profiles (Desktop and Favorites) for any .url (normal shortcut) or .website (pinned site) files on remote computers that contained a specific domain pattern and delete them.

    I ended up creating an Inventory powershell tool to run the script below. 

    Tool settings:

    Run Type: Remote

    Run As: Local System

    Powershell: 

    $list = gci C:\users\*\Desktop\* -include *.url, *.website -recurse | select-string -pattern "sub.domain.com"
    $list | foreach { rm $_.Path }
    $list2 = gci C:\users\*\Favorites\* -include *.url, *.website -recurse | select-string -pattern "sub.domain.com"
    $list2 | foreach { rm $_.Path }
    0
    Comment actions Permalink

Please sign in to leave a comment.