How to Create a Subfolder in VBS
Visual Basic Scripting (VBS) is a programming language used to automate processes using plain text files. The files have the .vbs extension, and they are executed when you double-click the file or place it in the startup directory for Windows. Windows network administrators use the files to map drives, delete and add folders and execute other applications. You can create a VBS file to add a subdirectory to a file folder location on the local user's machine.
Instructions
-
-
1
Open Notepad or an equivalent text editor. VBS files are plain text, so you can use any simple editor installed on your system.
-
2
Create the scripting object that creates the folder. This object is used for file manipulation including folders. The code below creates the file system object:
Set objFile = CreateObject("Scripting.FileSystemObject")
-
-
3
Create a subfolder. The code below creates the subfolder and assigns it to a variable. This variable can be used to manipulate the folder properties:
Set my_Folder = objFSO.CreateFolder("C:\folder\subfolder")
Replace the text within the "CreateFolder()" function with the location of the new subfolder on the user's machine. -
4
Print out the status of the creation. Use the console's "Echo" command to display results. The code below tells the user that the folder was created:
WScript.Echo "New folder created."
-
5
Save the file with the .vbs extension. Double-click the file on the hard drive. The VBS file executes and creates a new folder on the hard drive.
-
1