Solved

creating a vbs script

Posted on 2009-04-07
1
292 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 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