/build/static/layout/Breadcrumb_cap_w.png

How do I delete a file using a batch script (or better method) from all users' (but not THE all users) directories?

We have an old shortcut that has not deleted itself from a program we no longer use across all of our systems.  Is there a way to script the deletion of that file?  Its on some of the individual users' desktop.

1 Comment   [ + ] Show comment
  • Try the scripts posted at

    http://www.itninja.com/question/can-kace-somehow-inspect-the-properties-of-an-application-shortcut-lnk - flip1001 8 years ago

Answers (2)

Posted by: rileyz 8 years ago
Red Belt
1
Yes, yes you can.

PowerShell, or your prefered scripting language would be best, NOT batch.

Hopefully the shortcut hasn't been renamed.

How I would go about: search the C:\users directory for the shortcut, if found then delete it. Put a exception in the code for the AllUsers directory.
This might help.
http://stackoverflow.com/questions/8677628/recursive-file-search-using-powershell


Run the script as local system or some account that has access, SYSTEM would be best as no ACL fiddle will need to be done. 

Posted by: rockhead44 8 years ago
Red Belt
0
I ran this .bat file as an offline kscript to delete Office 2013 shortcuts. Not exactly what you are doing but may give you a starting point. 

======================================================================================

@echo off

Set scut="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013"

del /s /q /f %scut%\"InfoPath Designer 2013.lnk"

del /s /q /f %scut%\"InfoPath Filler 2013.lnk"

del /s /q /f %scut%\"Lync 2013.lnk"

del /s /q /f %scut%\"OneDrive for Business.lnk"

del /s /q /f %scut%\"OneNote 2013.lnk"

del /s /q /f %scut%\"Outlook 2013.lnk"

del /s /q /f %scut%\"Send to OneNote 2013.lnk"

Set scut="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Office 2013 Tools"


del /s /q /f %scut%\"Lync Recording Manager.lnk"

del /s /q /f %scut%\"Office 2013 Language Preferences.lnk"

del /s /q /f %scut%\"Office 2013 Upload Center.lnk"

del /s /q /f %scut%\"Telemetry Dashboard for Office 2013.lnk"

del /s /q /f %scut%\"Telemetry Log for Office 2013.lnk"

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ