Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating a vbs script

Posted on 2009-04-07
1
Medium Priority
?
334 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:Habib Z
1 Comment
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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