Solved

delete folder or format drive???

Posted on 2001-07-13
43
298 Views
Last Modified: 2007-11-27
I want to delete all the sub folder and files of a particular folder, how to do that (Kill cannot work as its for all file and not sub folders nad RmDr is for empty folder) while my subfolders are not empty, secondly how to fomrat a drive onceI am in windows???
0
Comment
Question by:fmufti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 9
  • 7
  • +8
43 Comments
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6280810

Set fs = CreateObject("Scripting.FileSystemObject")

fs.DeleteFolder "FolderName"

Vin.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6280812
What you are trying to do with this stuff?
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6280865
Formatting a disk:

Call Shell("c:\Winnt\system32\Format.com a:")

Why would you wnat to format a drive ?

Vin.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:shikima
ID: 6281079
"c:\winnt"? if i use win9X, how to call the program. and can i use a=shell(...) instead of "call"?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6281795
Simply do this
Call Shell("format.com a:")

hongjun
0
 

Expert Comment

by:bppraveen001
ID: 6281873
Hello fmufti,
    You can use FileSystemObject to delete Folders. If you call DeleteFolder function of FileSystemObject it will delete all the SubFolders and Files within that folder.
Eg in ASP:
    Set objFsp=Server.CreateObject("Scripting.FileSystemObject")
    objFsp.DeleteFolder(Server.MapPath("Folder_Name"))

Eg in VB:
'Take Reference for FileSystemObject (Projects->References->Microsoft Scripting Runtime)
    Dim objFsp as new FileSystemObject
    objFsp.DeleteFolder("D:\FolderName")

To format a Disk Try the following code:
a) For Windows95 and 98 OS
  Call Shell("C:\Windows\system\format.com" A:)
b)For WindowsNT
  Call Shell("C:\WinNt\System32\Format.com" A:)

bpp
0
 

Author Comment

by:fmufti
ID: 6282203
I have win200 advanced server and I want to delete WINNT folder and SYSTEM32 folder but since I get the permission denied error, I want the program jumps to another  folder and sub folder and so on.
I have one code but still its not perfect

Public Function KillFolder(ByVal FullPath As String) _
   As Boolean
   
'******************************************
'PURPOSE: DELETES A FOLDER, INCLUDING ALL SUB-
'         DIRECTORIES, FILES, REGARDLESS OF THEIR
'         ATTRIBUTES

'PARAMETER: FullPath = FullPath of Folder to Delete

'RETURNS:   True is successful, false otherwise

'REQUIRES:  'VB6
            'Reference to Microsoft Scripting Runtime
            'Caution in use for obvious reasons

'EXAMPLE:   'KillFolder("D:\MyOldFiles")

'******************************************
On Error Resume Next
Dim oFso As New Scripting.FileSystemObject

'deletefolder method does not like the "\"
'at end of fullpath

If Right(FullPath, 1) = "\" Then FullPath = _
    Left(FullPath, Len(FullPath) - 1)

If oFso.FolderExists(FullPath) Then
   
    'Setting the 2nd parameter to true
    'forces deletion of read-only files
    oFso.DeleteFolder FullPath, True
   
    KillFolder = Err.Number = 0 And _
      oFso.FolderExists(FullPath) = False
End If

End Function
I dont have ill intentions just a (project).
Secondly the format command should not pop up the dos screen on win98 system it shouh remain hidden ???
So delete follders on WIN2000, and format on WIN98, since I have mentioned that I want to format from within windows and the OS doest allow me so what to do??
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6282505
My two cents:

Drop "Call", drop the path, no ()'s:

Shell "format a:", vbHidden

Unless the user has (re)moved format.com, in which case the path won't do you much good anyway.


As for deleting the windows (????) folder: Since you can't remove a file that's in use, you won't get very far deleting those folders while windows is running. Format a floppy with the Win98 boot files and add this line to it's autoexec.bat file:

Deltree /y C:\WinNT

Then boot the floppy. I doubt the HD will boot up anymore since the Windows system is required on Win2K and you just deleted it, but it'll kinda do what you asked (remove winnt folder, but not from windows)...
0
 
LVL 5

Expert Comment

by:gwgaw
ID: 6282630
Try this to format a drive.

Const SHFD_CAPACITY_DEFAULT = 0 ' default drive capacity
Const SHFD_CAPACITY_360 = 3     ' 360KB, applies to 5.25" drives only
Const SHFD_CAPACITY_720 = 5     ' 720KB, applies to 3.5" drives only
Const SHFD_FORMAT_QUICK = 0     ' quick format
Const SHFD_FORMAT_FULL = 1      ' full format
Const SHFD_FORMAT_SYSONLY = 2   ' copies system files only (Win9x only)
Private Declare Function SHFormatDrive Lib "shell32" _
     (ByVal hwndOwner As Long, _
     ByVal iDrive As Long, ByVal iCapacity As Long, _
     ByVal iFormatType As Long) As Long

Private Sub Command1_Click()
    'iDrive = The drive number to format. Drive A=0, B=1 (if present, otherwise C=1),
    'and so on.
    SHFormatDrive Me.hwnd, 0, SHFD_CAPACITY_DEFAULT, SHFD_FORMAT_QUICK
End Sub
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6285134
Hi!

here's a file over the net for you:

Download...
http://www.vb-helper.com/Howto/fmtdisk.zip

Description: Format a disk (2K)

And this:

Download...
http://www.vb-helper.com/Howto/rrmdir.zip

Description: Remove a directory and everything it contains (5K)

That's it!

glass cookie : )

PS. Does it solve your problem?
0
 

Author Comment

by:fmufti
ID: 6286799
How to make my system with win2000 unable to boot(delete most critaical files)..think u all get the line straight now...!.
The format commands I'll check and let u know tommorow
I WILL RAISE THE POINTS(may be double)IF I GET THE SOLUTION THAT CRASHES MY WIN2000 SERVER PROMISED!
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6287084
DO NOT ANSWER THE LAST QUESTION!!!

fmufti, would you explain this last question?  

We are here to help keep equipment from failing, not destroying something.  This is highly suspect.  I will lock this question until I have it looked at.

ComTech
Community Support Moderator
0
 

Expert Comment

by:ComTech
ID: 6287187
kodiakbear, email me when you get this.

Thanks
ComTech
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6287694
Jee, as i suppossed
;)
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6287954
Creating a virus?
0
 

Expert Comment

by:ComTech
ID: 6288016
fmufti  I am waiting for an answer to my question!

ComTech
Community Support Moderator
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 6288025
fmufti,
I have suggested to ComTech that this question be deleted for the following reasons:

1)<<IF I GET THE SOLUTION THAT CRASHES MY WIN2000 SERVER>>
If that is your development pc what good will the code be to you after you have crashed it....  You will have to start all over again anyway.

2) The above statement from you sounds more like you are looking for code to crash another W2K server, which is against EE's Member Agreement.
http://www.experts-exchange.com/jsp/infoMemberAgreement.jsp

Read the lines:
Experts Exchange reserves the right to determine what constitutes Internet abuse and objectionable conduct. If Experts Exchange believes, in its sole discretion, that a violation of these Guidelines has occurred, it may take responsive action. Such action may /include, but not be limited to, permanent removal of illegal or inappropriate information or content, or suspension or termination of your membership and access to Experts Exchange Service

planning illegal activities, such as creating computer viruses

Unless you can post a VERY good reason for asking this question, ComTech or I will ask the EE Admins(after we have deleted this question) to remove your account from Experts Exchange.

kb
Community Support Moderator
Experts Exchange

P.S.
You can't double the points as there is a 300 point maximum.

To anyone reading this question please listen to ComTech's post and DO NOT Respond anymore to this Question.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6290065
ComTech, well done!!!!
0
 

Author Comment

by:fmufti
ID: 6290922
OK now listen.
I am working on Network Security in our campus, and we descover 2 WIN200 systems crash, when we investigate the lab incharge could not satisfy us, the reasons he gave was that some one in the system has deleted the files. I was given the task that is it possoible????. I have to prove that its not possible that once u log on as server operator u cannot do that. That guy is VB expert so I have put this Q in this forum???.
If u want u can check my credentials the history of the Qs that I have been asking(almost 98 over the last three years), I have refered this forum to over 10 of my friends so far in the past. If u still suspect me than I cannot say anything beyond that. Hope u have understood my point. BY THE WAY "glass_cookie" has proved its possible and I WAS WRONG.
0
 

Expert Comment

by:ComTech
ID: 6291118
fmufti, I tried to get a response from you last night.  Even the VB Experts found it fishy.  Can you understand how the reaction was when you posted *I WILL RAISE THE POINTS(may be double)IF I GET THE SOLUTION THAT CRASHES MY WIN2000 SERVER PROMISED!* Must have sounded?  and what exactly do you mean by that.

I have looked at your profile, and it looks okay.  I still want Ian to see this, it may well turn out to be nothing.  

We are not accusing you of wrong doing, but it did look suspect.  I just feel this needed more attention.

ComTech
Community Support Moderator
0
 

Author Comment

by:fmufti
ID: 6292107
U know, when ur job is at stake u feel very tensed and desperate. Infact the fault was with me as I could not convey my sense properly.  Hope u'll clear me of the suspicion, specially infront of the above Experts, as I was really very upset last night.
I could not reply u last day before yesterday becauase of my comitmens I could not check the email and was shocked to see what all has been going on in the last 24 hours!.
Hope things should have been cleared by Now.
0
 

Expert Comment

by:ComTech
ID: 6298907
fmufti, after consideration and your answers to me do finally lend me an explination.  Your last comment before I stepped in this looked to be very disturbing.  When you did not retun my request for speaking with you, it looked even worse.

After a brief investigation into your background here at EE, I see that along with your explination, that I recommend that you be reinstated in good faith.

To all the experts and all that were involved, please afford fmufti with grace an dignity.

If someone did actually help you, please post a question in the Topic Area, etitled "Points for xxxxx and in comment box reference this URL or question number and comment that it is for "help in resolving my problem.

As for myself and EE you are welcome to continue.

Thank you for the responces, and as far as I am concerned, you are back in good standing.

Thank you,
ComTech
Community Support Moderator

Ps. Be careful as to how questions and answers are worded, for your own protection.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6300646
I'm glad everything is solved : )

That's it!

glass cookie : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6300651
By the way, do I get the pts?

glass cookie : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6300653
- need to reach the 3000 pts/month quota for KPro subscription.
0
 

Expert Comment

by:ComTech
ID: 6300657
That depends on fmufti, whether or not he was hepled?

fmufti, this question is technically closed, it will remain in an open state so all involved will see it, and know that he is in good standing in the Community.

I did refund your points, so you are welcome to award as I explained above, or use them to start another question.

Thank you,
ComTech
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6300658
Read your profile. I am also a Singaporean. Just graduated from Singapore Poly. Now waiting for NS. What about you?

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6300663
glass_cookie,
Strange that you did not get 3000+ points this month. Your profile seems to be good. Must be busy over something this month.

hongjun
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6300821
Hey! You're also a Singaporean?

Well... exams started recently - kind of busy.  FYI, I'm in ACJC : )

Nice to know you, hongjun!

That's it!

glass cookie : )
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6300826
Not bad huh. You learn VB yourself? You got good record for VB.

hongjun
0
 

Author Comment

by:fmufti
ID: 6300963
Thanx ComTech. I am glad.
Well glass_cookie  ur points are at http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20154038
if glass_cookie and honguun dont mind, I would like to include my addres box if u dont mind, as I like VB people. My email is fmufti@softhome.net.
I am also a Web developer
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6301015
Hi fmufti!

If you want my email address, it's diamond_chip@hotmail.com.  By the way, your job sounds cool.

Thanks for the points!

Hi hongjun,

My secondary school started me with the little basics of VB in sec. 2.  From there, I got interested and read deeper into it : )  Thanks for the compliments : )

After starting c++ recently, I appreciate VB more : )  Did you learn VB yourself too?

That's it!

glass cookie : )
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6301020
Ya.
I learnt VB, ColdFusion and ASP myself. I like ASP best.

hongjun
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6301024
Wow...

I only know VB and c++ basics.

That's it!

glass cookie : )
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6301028
C/C++, etc learnt from school. But I don't like C/C++ anymore. Boring though I know it is really powerful.

hongjun
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6301031
I agree... boring but powerful.

Oops... gotta go now - GP. Lessons at 1:15 p.m.
0
 

Author Comment

by:fmufti
ID: 6301377
Hi, I know Borland C++ for DOS and Windows, Visual C++( not a master), visual Basic, SQL Server, want to learn ASP hongun any good book to learn ASP ????. By the way I am an electrical Enginer.
hongun like to share ur email????
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6301692
Wow... that's a lot : )
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6301711
C++ boring I think not :-P

Have you lot looked at WTL (Windows Template Library) it's great. Apps take a lot longer to write but you can do sooooo much more than VB.

Vin.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6301969
VincentLawlor, your comment makes sense. C++ is definitely more powerful than Visual Basic. But in my own preference, I prefer Visual Basic. That's all.

My ICQ: 36303538

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6301972
>>any good book to learn ASP
Try Beginning ASP 3.0 by Wrox.

hongjun
0
 

Author Comment

by:fmufti
ID: 6304185
VincentLawlor Can u throw some light on Windows Templates(Tutorial or Books) ) how it works???
hougjun Email???
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question