|
|
|
|
|
You are here...
VBScript - Create a Folder
This section explains how to create a folder(Also called directory) using vbscript. A folder can be created using the 'CreateFolder'
function of the file system object. The syntax of the 'CreateFolder' function is given below
Syntax: CreateFolder foldername
Here the argument 'foldername' is a mandatory argument. The folder will be created with this name.
If a folder with this name already exists then vbscript will show an error.
The following code creates a folder with a given name. If a folder exists with the same
name, you will get an error.
Create a Folder
Dim ObjFso
Dim StrFolderName
On Error Resume Next
StrFolderName = "C:\NewTestFolder"
Set ObjFso = CreateObject("Scripting.FileSystemObject")
ObjFso.CreateFolder StrFolderName
If Err.Number = 0 Then
WScript.Echo("Folder successfully created.")
Else
WScript.Echo("Folder cannot be created.")
End If
|
|