Solved

creating a vbs script

Posted on 2009-04-07
1
273 Views
Last Modified: 2012-05-06
Hi I would like to have the following done on the computers on the LAN.

I want a vbs script that will run on a schedule that will clean the following folders.

%userprofile%\Local settings\temp\*.*
%userprofile%\;local settings\temporay internet files\*.*
%windir%\temp\*.*

I would like the script to clean all the unused files and skip the ones that are in use. One problem I have is that does it find the location of these folders with no problems because most of these are hidden folders or do we need to apply attrib switch to make sure the script will run and find the location with no issues. Also I want to know if this script will need to run using admin account.

Thanks for you help
0
Comment
Question by:Zak
1 Comment
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 24099156
This is a simple batch file that would accomplish it - if you're really in need of a vbscript, I can post that as well (just seems simpler to do this in a batch).

You would need to either promote users to admins to remove windir\temp data, grant them change rights to that folder (which they may have - I think by default power users do), or schedule a separate task to run under system credentials to accomplish that.

Also - the temporary internet files will potentially remove 'all' cookies and history - most cases that may not be ideal (there are products that selectively delete tracking cookies only).  In addition, if the browser is in use, the files will not be removed.

Please note - this is a non-destructive script.  Remove the 'echo' from the last two textual lines to initiate deletion.
set t1="%temp%"

set t2="%userprofile%\local settings\temporary internet files"

set t3="%windir%\temp"
 

for %%a in (%t1% %t2% %t3%) do (

  for /d %%b in (%%a\*) do echo rmdir /s /q "%%b"

  echo del /q %%a

)

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

11 Experts available now in Live!

Get 1:1 Help Now