Script to delete downloads contents all users
I am looking to create a script to delete the contents of the downloads folder for all users on a workstation. Not the folder but its contents. .bat is fine. I cant seem to find the magic combo by googling. thanks
Community Chosen Answer
I wrote this now but haven't tested it. So, if it damages your systems you're on your own.
REM Assumes robocopy is installed
REM dummyFolder variable is an empty folder
REM that robocopy will use to clear the downloads folders
if exist "%dummyFolder%\." (exit 1)
if not exist "%dummyFolder%\." (exit 1)
for /d %%a in ("%profileFolder%\*") do (
if exist "%%a\Downloads\." (
Echo Clearing downloads of %%a\Downloads
REM take the echo command off for production
echo robocopy "%dummyFolder%" "%%a\Downloads" /MIR
REM delete dummy folder
rd /s /q "%dummyFolder%"