Wednesday, February 9, 2011

Script to Create a folder and delete a folder

'Create FolderOn Error Resume Next
dim objFSO

'new folder to create.  The parent folder must already exists
strFldr="C:\Neeraj"

set objFSO=CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder(strFldr)

set objFSO=Nothing

'Delete folder
'ANY FILES OR SUBDIRECTORIES WILL ALSO BE DELETED

On Error Resume Next
dim objFSO
'folder to delete
strFldr="C:\Neeraj"

set objFSO=CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder(strFldr)

set objFSO=Nothing

No comments: