Jump to content

Recommended Posts

Posted

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

 

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/display_script.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?code/shell/shfileopadv.htm

 

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

 

Or are those the only options available ?

Posted

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.

 

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

Posted

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 ?

Posted

AutoITs dir remove ?

 

; Delete C:\Test1 and all subdirs and files
DirRemove("C:\Test1", 1)

 

RMDIR ? - Does the same thing as the old DELTREE

 

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

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...