Solved

Delete temp files remotely

Posted on 2007-04-10
11
1,223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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