i found a VB script that uses FileSystemObject to delete every folder on a drive except ones i specify, my problem is that the FileSystemObject cannot see or enumerate folder with trailing / leading - period / space, but DIR command can,
I trying to run a command to delete all folders on a drive (it's from winPE during OS Deployment so it's ok) EXCEPT for the one i specify, this is part of what i work with which works fine but doesn't pick special named folders... is there a way i can use DIR command to feed the "Select Case"?
For each oFolder in oFSO.GetFolder(oEnvironment.Item("DestinationLogicalDrive") & "\").Subfolders
Select Case lcase(oFolder.Name)
Case "minint", "recycler", "system volume information", "deploy", "drivers", "_smstasksequence", "smstslog", "sysprep", "userstate"
oLogging.CreateEntry "Skipping " & oFolder.Path, LogTypeInfo
Case Else
oLogging.CreateEntry "Deleting " & oFolder.Path, LogTypeInfo
sCmd = "cmd /c rd ""\\?\" & oFolder.Path & """ /S /Q"
iRc = RunAndLog(sCmd, false)
TestAndLog iRc,"Execution: " & sCmd
If iRC <> 0 Then
If oFSO.FolderExists(oFolder.Path) Then
oLogging.CreateEntry "Failed to delete " & oFolder.Path & " will try to rename", LogTypeError
sCmd = "cmd /c rename """ & oFolder.Path & """ """ & oFolder.Name & ".bad"""
iRc = RunAndLog(sCmd, false)
TestAndLog iRc,"Execution: " & sCmd
If iRC <> 0 Then
If oFSO.FolderExists(oFolder.Path) Then
oLogging.CreateEntry "Failed to delete or rename " & oFolder.Path & " the image WILL fail with NTLDR", LogTypeError
' TODO: notify, sit and wait
End If
End If
End If
End If
End Select