Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delete temp files remotely

Posted on 2007-04-10
11
Medium Priority
?
1,251 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 1000 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 1000 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

610 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