+ Post New Thread
Results 1 to 3 of 3
How do you do....it? Thread, Proper syntax to delete folder from Multiple Profiles in Technical; Does anyone know what Syntax is needed to delete a certain folder from every profile on a machine. exp. ' ...
  1. #1

    Join Date
    May 2008
    Posts
    14
    Thank Post
    9
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Proper syntax to delete folder from Multiple Profiles

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

    ' ------ SCRIPT CONFIGURATION ------
    strFolderPath = "<FolderPath>" ' 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

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,144
    Thank Post
    113
    Thanked 518 Times in 447 Posts
    Blog Entries
    2
    Rep Power
    121
    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:

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

  3. Thanks to srochford from:

    soze (3rd June 2008)

  4. #3

    Join Date
    May 2008
    Posts
    14
    Thank Post
    9
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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?


    Quote Originally Posted by srochford View Post
    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:

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

SHARE:
+ Post New Thread

Similar Threads

  1. delete certain profiles
    By chrbb in forum Scripts
    Replies: 4
    Last Post: 4th February 2010, 05:15 PM
  2. Replies: 2
    Last Post: 17th April 2008, 11:25 AM
  3. Delete printers from Profiles
    By Simcfc73 in forum Windows
    Replies: 3
    Last Post: 15th January 2008, 06:29 PM
  4. Replies: 15
    Last Post: 19th September 2007, 10:46 PM
  5. Grep syntax for multiple srtings?
    By ChrisH in forum *nix
    Replies: 17
    Last Post: 14th October 2006, 08:20 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
  •