Using VBScript to delete files

Using Vbscript i would like to delete any batch file located under any User's Start Up Folder on Windows 2000. For example under the document and settings if i logged in with my user account "test" then I wouild like to delete any batch files found in C:\Documents and Settings\test\Start Menu\Programs\Startup... also if i looged in as "test2"  I wouild like to delete any batch files found in C:\Documents and Settings\test2\Start Menu\Programs\Startup. So this script would chage the location of the file according to the user that is logged in to the computer.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hope this provides a startup

Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemobject")
Set documentSettingFolder = FSO.GetFolder("C:\Documents and Settings\")
Set userFolders = documentSettingFolder.SubFolders
For Each userFolder In userFolders
      FSO.DeleteFile(userFolder & "\Start Menu\Programs\Startup\*.bat")
msgbox("Done deleting batch files")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gbarrientos: there is a special folder property that directly gives the path to the startup folder

set WshShell = WScript.CreateObject("WScript.Shell")
strStartup = WshShell.SpecialFolders("startup")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strStartup)
For Each x In f.files
      if right(,4)=".bat" then
      end if

/* hopefully this will help coz its doing some wonders for me, just put it as a function */

Public Function funtname(delDays as integer, scanDir as string)

   Dim fs As Object
   On Error GoTo errorHandler
   Set fs = CreateObject("Scripting.FileSystemObject")
   If Dir$(scanDir, vbDirectory) <> "" Then
      Dim fileDate As Date   ' Declare variables.
      Dim f, f1, fc
      Set f = fs.GetFolder(scanDir)
      Set fc = f.Files
      For Each f1 In fc
         fileDate = f1.DateCreated
         If DateDiff("d", fileDate, Now) > delDays Then

         End If

   End If
   Set fs = Nothing
   Exit Function
   Resume Next
End Function
gbarrientos: what you have accepted may not work if you execute the script with a non admin previlages besides it doesnt work as you asked. "So this script would chage the location of the file according to the user that is logged in to the computer. "

What I have mentioned does that I gets the startup folder depending on the user logged in. besides there would be no issues of rights since the user should normally be allowed to modify his/her settings.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.