Home » MSI Application Packaging » Useful Scripts for Custom Actions » Create a Nested Folder Structure using VBScript

Description:

The Filesystem Object cannot create a nested folder structure in a single invocation of the CreateFolder method.  For example, if we tried executing the following code it would return a ‘Path Not Found’ error unless c:\alkanesolutions\ already exists:

objFSO.CreateFolder “c:\alkanesolutions\test\”

The function below resolves this limitation.

Source:

Technet Forums

Script:

Dim FullPath : FullPath = "c:\alkanesolutions\test\folder"
Dim objFSO : Set objFSO = CreateObject("Scripting.FilesystemObject")

BuildFullPath FullPath

Sub BuildFullPath(ByVal FullPath)
  If Not objFSO.FolderExists(FullPath) Then
    BuildFullPath objFSO.GetParentFolderName(FullPath)
    objFSO.CreateFolder FullPath
  End If
End Sub

 

 

Comments have now been disabled. If you have a question to ask about this post please ask the community!