Lets say we have "%ProgramData%\Oracle Installation Products" as an INSTALLDIR and some extra folders are beng created during runtime and you dont want to delete INSTALLDIR but want to delete all subfolders then use below script:
Option Explicit
On Error Resume Next
Dim objshell, objFSO, StrprgData, objFolder, colSubfolders, objRegEx, colMatches
Dim Path, Test, objSubfolder
Set objShell=CreateObject ("wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder( StrprgData & "\Microsoft\Windows\Start Menu\Programs")
Set colSubfolders = objFolder.Subfolders
StrprgData = objShell.ExpandEnvironmentStrings("%ProgramData%")
For Each objSubfolder in colSubfolders
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "Oracle -"
Set colMatches = objRegEx.Execute(objSubfolder.Name)
If colMatches.Count = 1 Then
Path = StrprgData & "\Microsoft\Windows\Start Menu\Programs\"
If objfso.FolderExists ( Path & objSubfolder.Name & "\Oracle Installation Products\") Then
Test = StrprgData & "\Microsoft\Windows\Start Menu\Programs\" & objSubfolder.Name
objfso.DeleteFolder test
End If
End if
Next
Thank you for reading.