Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

delete folder or format drive???

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
fmufti
Asked:
fmufti
  • 9
  • 9
  • 7
  • +8
1 Solution
 
VincentLawlorCommented:

Set fs = CreateObject("Scripting.FileSystemObject")

fs.DeleteFolder "FolderName"

Vin.
0
 
Richie_SimonettiIT OperationsCommented:
What you are trying to do with this stuff?
0
 
VincentLawlorCommented:
Formatting a disk:

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

Why would you wnat to format a drive ?

Vin.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
shikimaCommented:
"c:\winnt"? if i use win9X, how to call the program. and can i use a=shell(...) instead of "call"?
0
 
hongjunCommented:
Simply do this
Call Shell("format.com a:")

hongjun
0
 
bppraveen001Commented:
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
 
fmuftiAuthor Commented:
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
 
KDivadCommented:
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
 
gwgawCommented:
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
 
glass_cookieCommented:
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
 
fmuftiAuthor Commented:
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
 
ComTechCommented:
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
 
ComTechCommented:
kodiakbear, email me when you get this.

Thanks
ComTech
0
 
Richie_SimonettiIT OperationsCommented:
Jee, as i suppossed
;)
0
 
hongjunCommented:
Creating a virus?
0
 
ComTechCommented:
fmufti  I am waiting for an answer to my question!

ComTech
Community Support Moderator
0
 
kodiakbearCommented:
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
 
Richie_SimonettiIT OperationsCommented:
ComTech, well done!!!!
0
 
fmuftiAuthor Commented:
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
 
ComTechCommented:
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
 
fmuftiAuthor Commented:
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
 
ComTechCommented:
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
 
glass_cookieCommented:
I'm glad everything is solved : )

That's it!

glass cookie : )
0
 
glass_cookieCommented:
By the way, do I get the pts?

glass cookie : )
0
 
glass_cookieCommented:
- need to reach the 3000 pts/month quota for KPro subscription.
0
 
ComTechCommented:
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
 
hongjunCommented:
Read your profile. I am also a Singaporean. Just graduated from Singapore Poly. Now waiting for NS. What about you?

hongjun
0
 
hongjunCommented:
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
 
glass_cookieCommented:
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
 
hongjunCommented:
Not bad huh. You learn VB yourself? You got good record for VB.

hongjun
0
 
fmuftiAuthor Commented:
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
 
glass_cookieCommented:
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
 
hongjunCommented:
Ya.
I learnt VB, ColdFusion and ASP myself. I like ASP best.

hongjun
0
 
glass_cookieCommented:
Wow...

I only know VB and c++ basics.

That's it!

glass cookie : )
0
 
hongjunCommented:
C/C++, etc learnt from school. But I don't like C/C++ anymore. Boring though I know it is really powerful.

hongjun
0
 
glass_cookieCommented:
I agree... boring but powerful.

Oops... gotta go now - GP. Lessons at 1:15 p.m.
0
 
fmuftiAuthor Commented:
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
 
glass_cookieCommented:
Wow... that's a lot : )
0
 
VincentLawlorCommented:
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
 
hongjunCommented:
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
 
hongjunCommented:
>>any good book to learn ASP
Try Beginning ASP 3.0 by Wrox.

hongjun
0
 
fmuftiAuthor Commented:
VincentLawlor Can u throw some light on Windows Templates(Tutorial or Books) ) how it works???
hougjun Email???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 9
  • 7
  • +8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now