public static IList ScanProgramFiles(string logicalPath, bool silent) { IList foldersWithExecutables = new List(); string tmp = "", dir = ""; foreach (string d in Directory.GetDirectories(logicalPath)) { if (!silent) { Console.WriteLine("Now scanning " + d + " for executables."); } foreach (string dirWithExe in ScanProgramFiles(d, silent)) { foldersWithExecutables.Add(dirWithExe); } dir = d; } foreach (string d in Directory.GetFiles(logicalPath)) { tmp = ExtensionOf(d); if (tmp == null) { continue; } if (tmp.ToLower() == "exe" || tmp.ToLower() == "bat" || tmp.ToLower() == "vbs") { foldersWithExecutables.Add(d); } } return foldersWithExecutables; }