Jump to content

RobPrince

Members
  • Posts

    1
  • Joined

  • Last visited

Reputation

0 Neutral

About RobPrince

Personal Information

  • Occupation
    IT Support Administrator
  • Location
    ENGLAND
  1. RobPrince

    VBS Scribt

    Hi Guys Im new to this forum and just started my new job, I have been working on abit of VBS scribt to delete files older than 2 days in a shared directory. It has to remove all files and folder in 1 particular directory called C:\share48. Problem being is that I get a dialog box which I dont want popping up. Secondly it also removes the shre48 folder which i dont want it to, its supposed to delete all files and folders below it. This is what i came up with: _______________________________________ Dim oFSO, oFolder, oFiles, oFile Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder("c:\share48\test") Set oFiles = oFolder.Files for each oFile in oFiles if oFile.DateLastModified > DateAdd("d", 2, Now()) then oFile.Delete True end if next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFolders = objWMIService.ExecQuery _ ("Select * from Win32_Directory where Name = 'c:\\share48'") For Each objFolder in colFolders errResults = objFolder.Delete Wscript.Echo errResults next or use this script but it also deleted the c:\share48 folder which I dont whant it to. strPath = "C:\share48" DeleteFolder strPath Function DeleteFolder(strFolderPath) Dim objFSO, objFolder Set objFSO = CreateObject ("Scripting.FileSystemObject") If objFSO.FolderExists(strFolderPath) Then objFSO.DeleteFolder strFolderPath, True End If Set objFSO = Nothing End Function ___________________________________________________________ Please Help ^^ cheers guys.
×
×
  • Create New...