Solved

Delete temp files remotely

Posted on 2007-04-10
11
1,180 Views
Last Modified: 2008-11-06
Hi,

I have many machines which is detected by my antivirus which says it has found some unwanted application in temp folder.Is it possible to delete all these machine's Temp folders.A script or tool will help.
Like put in all the machine names in a txt file the script need to seach for the machines and clear the temp fol;der remotely.

Is it possible.

Thanks
Sharath
0
Comment
Question by:bsharath
  • 5
  • 4
  • 2
11 Comments
 
LVL 87

Expert Comment

by:rindi
ID: 18887642
You could add this to the login script, so temp folders are emptied at logon. Something like this:

del %SystemRoot%\temp\* /F /S /Q
del %userprofile%\local Settings\Temp\* /F /S /Q
0
 
LVL 11

Author Comment

by:bsharath
ID: 18888457
If i need to put it in a bat file and execute it on the local machine this does not work
0
 
LVL 87

Accepted Solution

by:
rindi earned 250 total points
ID: 18888528
Are there any errormessages? Also try using "":

del "%SystemRoot%\temp\*" /F /S /Q
del "%userprofile%\local Settings\Temp\*" /F /S /Q

And try it inside the logon script. Do you use Active Directory?
0
 
LVL 11

Author Comment

by:bsharath
ID: 18888544
Thanks this worked

del "%SystemRoot%\temp\*" /F /S /Q
del "%userprofile%\local Settings\Temp\*" /F /S /Q

But what about the folders in it.
0
 
LVL 87

Expert Comment

by:rindi
ID: 18888639
The /S switch should delete the files in the subdirs.
0
 
LVL 11

Author Comment

by:bsharath
ID: 18888648
Deleting the subdirs??
0
 
LVL 87

Expert Comment

by:rindi
ID: 18888829
For that you'll probably require a 3rd party utility, like deltree, and copy it into the windows folder, then use:

cd "\%SystemRoot%\temp\"
deltree *

and

cd "\%userprofile%\temp\"
deltree *

http://alter.org.ua/en/soft/win/deltree/
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18888915
You can use rmdir (rd) also...

Here's a batch file that will do the cleanup of those two folders...
It's in disabled mode, meaning it won't do the deletion.  If you find that it's displaying the correct path/files, uncomment the two related lines that are listed below these two:
echo y| echo del %fld% /f /q
for /f "delims=" %%t in ('dir %fld% /ad /b') do echo rmdir /s /q "%fld%\%%~t"




@echo off
for %%a in (%systemroot%\temp "%userprofile%\local settings\temp") do call :process %%~sa
goto :eof

:process
set fld=%1
echo y| echo del %fld% /f /q
REM The next line will actually perform the deletion
REM echo y| del %fld% /f /q
for /f "delims=" %%t in ('dir %fld% /ad /b') do echo rmdir /s /q "%fld%\%%~t"
REM The next line will actually perform the deletion
REM for /f "delims=" %%t in ('dir %fld% /ad /b') do rmdir /s /q "%fld%\%%~t"
0
 
LVL 11

Author Comment

by:bsharath
ID: 18889964
sirbounty:

what should i remove to uncomment
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
ID: 18889982
Make sure its displaying the folders and files you expect then simply use this version...


@echo off
for %%a in (%systemroot%\temp "%userprofile%\local settings\temp") do call :process %%~sa
goto :eof

:process
set fld=%1
echo y| del %fld% /f /q
for /f "delims=" %%t in ('dir %fld% /ad /b') do rmdir /s /q "%fld%\%%~t"
0
 
LVL 11

Author Comment

by:bsharath
ID: 18890049
Can i do this on a remote machine remotely.From my machine i need to delete all the machines temp file in the file i have mentioned the machine names
0

Join & Write a Comment

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now