for /d %%d in ("%userprofile%\..\*.*") do rd "%%d\local settings emp" /s /q
Save this as a .bat or .cmd file. Assuming you’re running an OS newer than WinME or WinNT, this will destroy all files & folders beneath the temp folder for each user profile on the machine it’s executed on.
Naturally, the ability to delete files & folders depends on security, so a low-privelege user who executes this will be unable to clean out other user’s temp files, while an admin executing this will clean the whole machine.
To test it out, insert the word “echo” between “do” & “rd” in line 2 & it will display the commands it would execute instead of actually executing them.
You don’t have to put the .cmd file on the target machine; it can reside on a central file share accessible to the target machine. But you do have to execute the code on the target machine.
If you already have a login or maintenance batch file all your machines run, you can just insert my line 2 into that file. It’s designed to not depend on or affect any surrounding execution context.
If you want to execute this code ON a central machine which reads & deletes files on OTHER machines across the network we’d need a few minor changes.