Delete TEMP files of multi users with single click | Nagarams Blog

Tuesday, 12 August 2014

Delete TEMP files of multi users with single click

Rate this Post:

 
There are so many scripts and tools over the internet  to clean the temporary files in windows. The problem with some tools or scripts is that, they are specific to the particular user in which you have currently logged in. Then what will be the situation if your OS had 100 number of user accounts ???  Will you log-in to the 100 number of users individually and run the scripts on every user session?!!!
Here is the simple answer for that ...
              Just one click is enough to delete the specific temporary file for all user accounts or specific user from the currently logged in session. All you need to do this is such a Potential Script and Admin rights.
The scenario is different with the user names you have assigned. The user names may be user1,user2 ......user100 or unique styles with ram, lakshaman, jcob, williams.... In both the cases you can run scripts, in the first case you can run the script for all the users at a time by simply giving the count(total no of users) but in the second case you have to enter the user name.

For the first case where all the names are same except the last digit(like user1,user2,user3....) you can run the following script
```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
@echo off
:a
set /a count=1
:b
echo user%count%
FOR /D %%p IN ("C:\users\user%count%\Appdata\Local\temp\*.*") DO rmdir "%%p" /s /q
del  C:\users\user%count%\Appdata\Local\temp\*.* /q
del C:\TEMP\*.* /q
del C:\Windows\Temp\*.* /q
rd /s /q %systemdrive%\$Recycle.bin
set /a count=count+1
if %count% equ 31 goto :end
goto :b
:end
echo.
echo.
echo Deletion of temp files for all users is finished
echo.
echo.
set /p DUMMY=Hit ENTER to exit...

```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
  • In the above script it will delete the temp files from C:\temp,C:\windows\temp, %userprofile%\Appdata\Local\temp, recycle bin of all the users.
  • You can increase the no.of users by changing the value in if %count% equ 31 goto :end  to the desired (in my case i have given '31' for 30 number of users).
  • You can add the additional locations to delete temp files by placing the appropriate paths above the set /a count=count+1 line in the script. 
 
For the second case where the user names are different you can use the following script

```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
@echo off
:a
set /p n=Enter Username:
FOR /D %%p IN ("C:\users\%n%\Appdata\Local\temp\*.*") DO rmdir "%%p" /s /q
del  C:\users\%n%\Appdata\Local\temp\*.* /q
del C:\TEMP\*.* /q
del C:\Windows\Temp\*.* /q
rd /s /q %systemdrive%\$Recycle.bin
echo.
echo.
echo Deletion of temp files for %n% is finished
echo.
echo.
set /p DUMMY=Press Enter for another user
cls
goto :a


``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
  • while running the above script, enter the user name that you want to delete the temp files
  • You can add the additional locations to delete temp files by placing the appropriate paths 
Note: In both the cases, the script can only deletes the normal files and it can not delete the system protected, hidden files or the files those are accessing by the other processes. So, delete all of these just take the owner ship of a files or change the attributes.


You may also like:

How to give Admin rights to a specific User or All Users for an Application 

Automatic Proxy for Mozilla Firefox for all the users in windows OS
How to modify IPv4 settings via CMD or. Bat file
Add a large number of users with specific permissions
Forgot Windows Log-In Password
Forgot windows log-in Password-2 

Thank you
Please Leave a comment

No comments :

Post a Comment