+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, faster way to delete in Coding and Web Development; I know in vbs you can use the FSO to delete files , ie : Code: set obtainfolder = fso.GetFolder(PathFolder) ...
  1. #1

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,762
    Thank Post
    3,271
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365

    faster way to delete

    I know in vbs you can use the FSO to delete files , ie :

    Code:
    set obtainfolder = fso.GetFolder(PathFolder)    
    	obtainfolder.Delete true       
    End Select
    The other option would be to use comspec with cmd ie :


    http://www.computerperformance.co.uk/ezine/ezine80.htm

    and to run the rmdir command or deltree or something to that effect ( in which case you may as well just use a bat script )

    Was wondering if there was another way in vbs to delete files and folders recursively minus the exceptions of folders such as Default, All Users, etc as per or similiar to this script :

    http://www.wisesoft.co.uk/Scripts/di...ipt.aspx?id=14

    Just seems to take a long time to delete local profiles using the FSO.

    The only other option that may be possible that I can think of would be to make an ocx or something to that effect in vb6 that used the SHFileoperation or something simliar as per this URL :

    http://vbnet.mvps.org/index.html?cod...hfileopadv.htm

    So all that aside is there another way in vbs to do it faster ?

    Or are those the only options available ?

  2. #2
    OutLawTorn's Avatar
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    216
    Thank Post
    8
    Thanked 8 Times in 8 Posts
    Rep Power
    32

    Re: faster way to delete

    The easiest option would be to run delprof. It can be run as a logoff script, or i tend to have a batch file set up that runs it remotely.

    Alternatively, i have the following to remove all files and folders from a directory, you might be able to modify it to suit your needs.

    Code:
    Const LocalDocumentsFolder = "Q:\public\"
    set objFSO = createobject("Scripting.FileSystemObject")
    set objFolder = objFSO.GetFolder(localdocumentsfolder)
    
    on error resume next
    
    for each fldr in objFolder.SubFolders
    	if not isexception(fldr.name) then
    		objFSO.DeleteFolder fldr.path, True
    	end if
    next
    
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.DeleteFile "Q:\public\*", True

  3. #3

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,762
    Thank Post
    3,271
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365

    Re: faster way to delete

    I know about delprof hence the reason why I mentioned using comspec with cmd in vbs to launch items such as delprof ( Sorry I forgot to mention it in the original post )

    Was just wondering if the above in my original post were the only ways to delete files through vbs ?

    If not then what are the other ways ?

  4. #4

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    Re: faster way to delete

    AutoITs dir remove ?

    Code:
    ; Delete C:\Test1 and all subdirs and files
    DirRemove("C:\Test1", 1)
    RMDIR ? - Does the same thing as the old DELTREE

    Code:
    RMDIR [/S] [/Q] [drive:]path
    RD [/S] [/Q] [drive:]path
    
     /S      Removes all directories and files in the specified directory
             in addition to the directory itself.  Used to remove a directory
             tree.
    
     /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

  5. #5
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: faster way to delete

    Can't really see anyway to vbscript without FSO if you want to delete a folder.

    BTW. its been mentioned before but just deleting the profiles directory does not clean up your registry.

SHARE:
+ Post New Thread

Similar Threads

  1. We are faster
    By Dos_Box in forum General EduGeek News/Announcements
    Replies: 16
    Last Post: 30th September 2007, 11:31 AM
  2. Go about investigating how I can get faster internet speeds
    By DavidB4910 in forum How do you do....it?
    Replies: 7
    Last Post: 30th March 2007, 10:43 AM
  3. UK supercomputer sets faster pace
    By EvLPhenom in forum IT News
    Replies: 1
    Last Post: 8th November 2006, 03:32 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •