Solved

Delete temp files remotely

Posted on 2007-04-10
11
1,193 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
 
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Synchronize a new Active Directory domain with an existing Office 365 tenant
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now