Jump to content

Recommended Posts

Posted

Does anyone know what Syntax is needed to delete a certain folder from every profile on a machine. exp.

 

' ------ SCRIPT CONFIGURATION ------

strFolderPath = "" ' e.g. "d:\temp"

' ------ END CONFIGURATION ---------

set objFSO = CreateObject("Scripting.FileSystemObject")

ObjFSO.DeleteFolder("C:\Documents and Settings\qt34064\Documentum\UCF")

WScript.Echo "Successfully deleted folder"

 

I want to remove it from Qt34065, Qt23404 and so on. How can I edit this in order for this to happen?

 

Thx

Posted

I'm guessing you're trying to delete the folder "documentum" and everything under it that's in any user profile folder on the machine?

 

If so then this should work:

 

set ofso=createobject("scripting.filesystemobject")
sRoot="c:\documents and settings\"
sFolder="documentum"
set oFolder=ofso.getfolder(sRoot)
for each oSubFolder in oFolder.subfolders
 sName=sRoot & oSubFolder.name & "\" & sFolder
 if ofso.folderexists(sName) then
   'wscript.echo sName
   ofso.deletefolder(sRoot & sName & "\" & sFolder,true)
 end if
next

 

the wscript.echo line is for testing; what I do with something like this is to leave in the echo line but comment out the delete line - that way I can see what folders are going to be deleted before it all goes horribly wrong :-)

 

When you are sure you're working with the right set of folders then you can comment out the echo line and uncomment the delete line.

  • Thanks 1
Posted

I'm trying to delete the UCF directory under Documentum for every profile, so can I just change the sFolder= to UCF instead of Documentum?

 

 

I'm guessing you're trying to delete the folder "documentum" and everything under it that's in any user profile folder on the machine?

 

If so then this should work:

 

set ofso=createobject("scripting.filesystemobject")
sRoot="c:\documents and settings\"
sFolder="documentum"
set oFolder=ofso.getfolder(sRoot)
for each oSubFolder in oFolder.subfolders
 sName=sRoot & oSubFolder.name & "\" & sFolder
 if ofso.folderexists(sName) then
   'wscript.echo sName
   ofso.deletefolder(sRoot & sName & "\" & sFolder,true)
 end if
next

 

the wscript.echo line is for testing; what I do with something like this is to leave in the echo line but comment out the delete line - that way I can see what folders are going to be deleted before it all goes horribly wrong :-)

 

When you are sure you're working with the right set of folders then you can comment out the echo line and uncomment the delete line.

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...