[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

Ang

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

Next



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








Regards, 
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







To
"thin@xxxxxxxxxxxxx" <thin@xxxxxxxxxxxxx>


cc




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

 

Cheers,

Jeremy.

 

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
folders

 

Hi



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?



Thanks

Ang





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


 

Hi,

 

You might want to look at
this:

http://www.computing.net/answers/programming/vbscript-to-delete-all-subfolders/14650.html

 

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

 

i.e.

 

@echo off

rmdir /s /q somedir

mkdir somedir

 

 

 



Regards



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

www.polyco.co.uk

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

 

Hi 



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




C:\TEST 

        FOLDER1 

        FOLDER2 

        etc 



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



Thanks 


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: