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
Answers (2)
Please log in to answer
Posted by:
rileyz
8 years ago
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
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
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"
http://www.itninja.com/question/can-kace-somehow-inspect-the-properties-of-an-application-shortcut-lnk - flip1001 8 years ago