Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logon script

Status
Not open for further replies.

elwell1

Technical User
Feb 24, 2006
2
US
I have a batch file that will delete all temp, temporary internet files, cookies, empty the prefetch folder and perform a disk cleanup

I was told i should use VBS for this, i am clueless with VBS, can anyone tell me where i could find such code? even it if doesnt do a disk clean up, it would be fine.

Kevin Elwell
elwell1@gmail.com
 
For starters I would take a look at my login script FAQ faq329-5798.

To be able to clear out a folder is an easy task with VBScript.

This sample demonstrates how to clear out both files and subfolders.
Code:
'==========================================================================
'
' VBScript Source File -- 
'
' NAME: CleanBadMail.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]	
' Copywrite (c) 2003 All rights reserved
' DATE  : 09/10/2003
'
' COMMENT: 
'
' This script will list all filtered and quarantined SPAM mail, check that 
' the files are more than 30 days old and then delete them.
' This file is to be scheduled to run each day.
'=====================================

Path1 = "E:\Program Files\Exchsrvr\Mailroot\vsi 1\BadMail"
Path2 = "E:\Program Files\Trend\SMCF\Quarantine"


Dim fso 
Dim oFolder
Dim oFile
Dim oSubFolder

  Set fso = createobject("Scripting.FileSystemObject")
  
   Set oFolder = fso.GetFolder(Path1)
  
  For Each oFile In oFolder.files
   	If DateDiff("d", oFile.DateCreated,Now) > 30 Then
    	oFile.Delete True
    End If
  Next


Set oFolder = fso.GetFolder(Path2)
Set colSubfolders = oFolder.Subfolders

For Each oSubfolder in colSubfolders
   	If DateDiff("d", oSubFolder.DateCreated,Now) > 30 Then
		fso.DeleteFolder(oSubFolder)
	End If
Next

Set oSubFolder = Nothing
Set oFolder = Nothing
Set fso = Nothing

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top