Archive for tag: vbscript

VBscript Create Folder

Here is a simple bit of VBscript code whidch we use a lot.

Imagine you have a script which needs to create a folder on the PC it is executing on if that folder doesn't already exist.

Here is a simple function that when called will check for the folder's existance, and if not found, will create it. There is no fancy error checking but will work fine if all permissions are OK.

Private Sub CheckFolder(ByVal f_Spec)
Dim fs As Scripting.FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")
  If fs.FolderExists(f_Spec) Then
    Set fs = Nothing
    Exit Sub
    fs.CreateFolder f_Spec
    Set fs = Nothing
  End If
End Sub

Using the script is just a case of calling it like this

CheckFolder "C:\Docs\TestFolder"


If it doesn't exist already, it will be created.

IT Support Kent

We are one of Kent's leading providers of managed IT Support services to SME and non-profits in Kent and London. Click the link below for more information.

IT Support Kent and London

Software Development Kent

Our software development team create web based database systems that help you to streamline business processes. Click the link below for more information.

Software Development Kent and London

Office 365 support and consultancy

Our dedicated cloud services team specialise in Office 365 consultancy, migration and implementation.

Office 365 support and consultancy