Solved

Delete temp files remotely

Posted on 2007-04-10
11
1,204 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 88

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 88

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 88

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 88

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

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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