vbscript删除母文件夹

如果需要检查母文件夹是否为空,空则删除的话,VBS代码如下:

Dim fso, Folder2Delete, FolderPath, parentFolder
FolderPath =  "C:\Program Files (x86)\My App\1"
MsgBox FolderPath

Set fso = CreateObject("Scripting.FileSystemObject")
Folder2Delete = fso.GetFolder( FolderPath )
MsgBox Folder2Delete

parentpath = fso.GetParentFolderName( Folder2Delete )
MsgBox parentpath

If fso.FolderExists(Folder2Delete) Then
  fso.DeleteFolder(Folder2Delete)
End If

Set parentFolder = fso.GetFolder( parentPath )
MsgBox parentFolder
    
If parentFolder.Files.Count = 0 And parentFolder.SubFolders.Count = 0 Then
	MsgBox "The folder is empty"
	fso.DeleteFolder(parentFolder)
Else
	MsgBox "The folder contains files and/or subfolders"
End If

Set fso = Nothing



你可能感兴趣的:(InstallShield,2012,VBScript)