PC Review


Reply
Thread Tools Rate Thread

Problem with deleting files through WMI

 
 
New Member
Join Date: Jul 2005
Posts: 1
 
      18th Jul 2005
I want to make a script that deletes the folder and all the files in it. The script i am using is:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = 'c:\\Documents and Settings\arehman\Desktop\test'")

For Each objFolder in colFolders
errResults = objFolder.Delete
Next

when i run the bat file with the above script a screen flashes on the monitor and nothing else happens. I also restarted the services. Same problem.
Someone please tell me where did i go wrong.
Thanks
 
Reply With Quote
 
 
 
 
New Member
Join Date: Aug 2005
Posts: 1
 
      31st Aug 2005
Well, I'm looking for the same thing. But some pointers. Run in a cmd window using cscript and you will get a persistent execution. You can code in echo markers to locate where you are when bad things happen. Or download and enable the debugger (search Microsoft).

What I need is to delete an entire tree of files and folders, and I can't seem to get the regular expressions to work in the way I think they should (starting with the same script you have, BTW). I see a lot of questions about this. Surely someone (please!) has faced this and solved it. Or is there a "force" mechanism to force deleting a folder even if it has content?

Best regards

Fred
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem deleting files Charlie Tame Windows XP General 3 19th Sep 2005 04:27 AM
Problem Deleting files =?Utf-8?B?Q29saW4=?= Windows XP Basics 1 31st Aug 2005 02:30 PM
re: problem deleting .exe files =?Utf-8?B?am9uY2hvbmc=?= Windows XP Help 3 24th Oct 2004 05:33 PM
Problem deleting Files Maxwell Windows XP General 1 20th Jun 2004 04:30 PM
problem deleting files =?Utf-8?B?dHR0?= Windows XP General 0 5th Jan 2004 04:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:18 AM.