Eswar Koneti's Blog

All about Configmgr and its connected objects…….

  • About Author
      View eswar koneti's LinkedIn profile
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 106 other subscribers

  • Awards


  • FaceBook Updates

  • Catagories

  • Meta

  • Copyright!

    All the blog posts in this website are owned by Eswar Koneti and may not be reused in any mode without prior approval of Eswar Koneti. You may quote one paragraph from the blog posts if you link to the original blog post.
    Happy Reading!

VB Script to check if folder exist and delete on remote machines

Posted by Eswar Koneti on 1st August 2012

Script to check files on remote computer and delete them if they are available.

ON ERROR RESUME NEXT

Set objfso = CreateObject ("Scripting.FileSystemObject")
Set computerList = objfso.OpenTextFile ("C:\Scripts\computerList.txt", 1)
Set outputList = objfso.OpenTextFile ("C:\Scripts\outputList.txt", 2, True)

Do While Not computerList.AtEndOfStream

strComputer = computerList.ReadLine
If objFSO.FolderExists("\\" & strComputer & "\F$\oldfiles") Then
Set strFolderPath = objFSO.GetFolder("\\" & strComputer & "\f$\oldfiles")

objFSO.DeleteFolder strFolderPath, True
outputList.WriteLine strComputer & vbTab & "oldfiles folder deleted"

Else

outputList.WriteLine strComputer & vbTab & "Oldfiles folder does not exist"

End If

loop

Change the Bold letters as necessary.

Tags: , ,
Posted in Scripting | 2 Comments »