VB Script to delete a folder

Posted by admin | HTML Code , tips or suggestions | Saturday 18 April 2009 4:04 pm

I never thought I would be enjoying creating scripts but I find myself into playing around with scripts at times due to the nature of my job. Here is something I can share with anyone that needs a simple script that does the job It can either be launched locally or you can use a command line function to launch it remotely.

-Open a notepad window
-Copy paste the code below
-Replace the value in the code that corresponds to your need
-Save file as .vbs
-Done

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)
Set colFolders = objWMIService.ExecQuery _
(“Select * from Win32_Directory where Name = ‘c:\\replacethisvalue_with_yours’”)
For Each objFolder in colFolders
errResults = objFolder.Delete
Wscript.Echo errResults
Next

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Increase Page Rank Google