[THIN] Re: [nosig] RE: OT - Assistance with script to delete folders

  • From: Angela Smith <angela_smith9@xxxxxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Thu, 30 Sep 2010 07:18:51 +1000

Script works great - thanks very much


To: thin@xxxxxxxxxxxxx
CC: thin@xxxxxxxxxxxxx; thin-bounce@xxxxxxxxxxxxx
Subject: [THIN] Re: [nosig] RE: OT - Assistance with script to delete folders
From: scott.delagrange@xxxxxxxxxxxxxx
Date: Tue, 28 Sep 2010 11:16:06 -0400

Try this....

folderPath = "C:\TTemp"

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSubfolders = objWMIService.ExecQuery _

    ("Associators of {Win32_Directory.Name='" & folderPath & "'} " _

        & "Where AssocClass = Win32_Subdirectory " _

            & "ResultRole = PartComponent")

Set objFSO = CreateObject("Scripting.FileSystemObject")

For Each objFolder in colSubfolders

    WScript.Echo objfolder.name


    objFSO.DeleteFolder(objFolder.Name), True


objFSO.DeleteFile(folderpath & "\*.*"), DeleteReadOnly

Scott DeLagrange

CIBA VISION Corporation

IT Global Manufacturing & Supply

CIBA VISION Corporation

11460 Johns Creek Parkway

Johns Creek, GA 30097

Phone: 678-415-3299

Fax: 678-415-2609

Email : Scott.DeLagrange@xxxxxxxxxxxxxx

Web : http://www.CIBAVISION.com

Jeremy Saunders <Jeremy.Saunders@xxxxxxxxxxxxxx>

Sent by: thin-bounce@xxxxxxxxxxxxx
09/28/2010 10:22 AM

Please respond to


"thin@xxxxxxxxxxxxx" <thin@xxxxxxxxxxxxx>


[THIN] Re: [nosig] RE: OT - Assistance
with script to delete folders

Everything can be scripted
to achieve whatever you want. This is the power of scripting. From the
vbscript you can use icacls.exe to change folder permissions.





From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx]
On Behalf Of Angela Smith

Sent: Tuesday, 28 September 2010 7:29 PM

To: thin@xxxxxxxxxxxxx

Subject: [THIN] Re: [nosig] RE: OT - Assistance with script to delete



I cannot delete the top level as the top folder has specific rights which
are not inherited..  Would be good if I can delete everything except
the top folder.  Otherwise I would need to script the ACL modifications
also.  Users group needs modify access to the top folder..  Can
this be scripted easily?



From: it@xxxxxxxxxxxx

To: thin@xxxxxxxxxxxxx

Date: Tue, 28 Sep 2010 08:52:54 +0100

Subject: [THIN] [nosig] RE: OT - Assistance with script to delete folders




You might want to look at



Easiest way would be to create
a script to remove the top level folder and everything inside, and then
recreate the top level folder.




@echo off

rmdir /s /q somedir

mkdir somedir





IT Helpdesk

IT Support

BM Polyco Ltd

Tel: 020 8443 9002 | Fax: 020 8443 9011 | E-Mail: it@xxxxxxxxxxxx

Crown Road, Enfield, Middlesex, EN1 1TX

Registered in England No 1368213


P Please
consider the environment before printing this e-mail.

From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx]
On Behalf Of Angela Smith

Sent: 28 September 2010 08:12

To: thin@xxxxxxxxxxxxx

Subject: [THIN] OT - Assistance with script to delete folders



Im trying to create a script that runs on server startup that deletes all
files/folders in a specific folder but without deleting the top level folder





I tried using rmdir c:\Test\ /s /q but this deletes the test folder.  I
need to delete all subfolders except c:\test.  Any ideas on how I
can do this?? Citrix Server is running
on Windows 2003


Click here
to report this email as spam.

BM Polyco Ltd Disclaimer

This e-mail and the information it contains are confidential. If you have
received this message in error please notify us immediately. You should
not use or copy it for any purpose nor disclose its contents to any other
party. The contents of this communication are advisory and are not binding
on the Company unless supported by authorised documentation. 

This e-mail has been scanned for content by Websense
Hosted Email Security.

Confidentiality and Privilege Notice 

This document is intended solely for the named addressee.  The information
contained in the pages is confidential and contains legally privileged
information. If you are not the addressee indicated in this message (or
responsible for delivery of the message to such person), you may not copy
or deliver this message to anyone, and you should destroy this message
and kindly notify the sender by reply email. Confidentiality and legal
privilege are not waived or lost by reason of mistaken delivery to you.


Attachment: ATT00001
Description: GIF image

Other related posts: