Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Praise should be given to the Forum managers or the Tipmasters - they are what make it work - give them extra recognition!!! They are timely (prompt - unlike ACTUAL support sites) and on the ball!!!..."

Geography

Where in the world do Tek-Tips members come from?

How to give inputs from a text file

dheerajreddy926 (Programmer)
15 Apr 12 3:43
Hello All,

I am not a vb expert . I am planing to do an automation to delete log archives periodically from a location.we have around 100+ servers . I have got a VB script to delete folders based on path given .But i want the script to delete all archive folders in all servers . the path for Windows machines are \\srvrname\d$\sea77\siebsrvr\LOGARCHIVE and for AIX it is \\srvrname\Siebel\enterprises\siebel_aix\srvrname\logarchive.

Script i got for deleting logarchive for a particular server is
.............................................................
Const strPath = "D:\path"

Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")



Call Search (strPath)

WScript.Echo"Done."



Sub Search(str)

    Dim objFolder, objSubFolder, objFile

    Set objFolder = objFSO.GetFolder(str)

    For Each objFile In objFolder.Files

        If objFile.DateLastModified < (Now() - 3) Then

            objFile.Delete(True)

        End If

    Next

    For Each objSubFolder In objFolder.SubFolders

        Search(objSubFolder.Path)

        ' Files have been deleted, now see if

        ' the folder is empty.

        If (objSubFolder.Files.Count = 0) Then

            objSubFolder.Delete True

        End If

    Next

End Sub

------------------------------------------------------------------
I want to schudule this job every midnight so that it clears logarchives in all servers which are 3 days old .


Thanks in advance!
Dheeraj.
 
guitarzan (Programmer)
15 Apr 12 12:22
Did you try setting strPath to the paths to the servers?
Geates (Programmer)
16 Apr 12 9:40
The search function seems a little overkill.  Why not...

CODE

set objFSO = CreateObject("Scripting.FileSystemObject")

function deleteArchive(strFolder)
   if (objFSO.FolderExists(strFolder)) then
      if (objFSO.GetFolder(strFolder).DateLastModified < (now - 3)) then
         objFSO.deleteFolder strFolder
      end if
   end if
end function

arrServers = an array of server names
foreach strServer in arrServers
   strServerPath = "\\" & strServer & \d$\sea77\siebsrvr\LOGARCHIVE"
   strAIXPath = "\\" & strServer & "\Siebel\enterprises\siebel_aix\srvrname\logarchive"
   deleteArchive strServerPath
   deleteArchive strAIXPath
next

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again.  Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close