/* ****************************************************************************** @SriptName: App launcher.xys @Author: IT Services & Consulting Ulf Kohlmorgen @Created on: 2015-10-15 13:20:49 @Last modified: 2018-07-06 23:13:26 @Function: Find and lauch applications (from a filterable window) @Current version: v0.3 +++ major new feature + new feature * changed feature - removed feature % improved performance ! fixed minor bug !!! fixed major bug ****************************************************************************** */ end compare(, "19.00.0302", "v") == -1, "This script requires at least v19.00.0302, terminating now!"; $iniFile = self("path") . "\" . self("base") . ".ini"; $iniContent = <<<>>> [General] Window_Width=400 Window_Height=700 Remove_Lnk_Extension=1 Remove_Exe_Extension=1 Default_Extensions=exe;lnk Use_Separators=1 Separator_Above=1 Separator_String=---------- [#SectionName#] ---------- Seperator_Icon=:queue ; Paths = Single or multiple paths, must be separated by "|" ; Recursive = Empty or 0: No recursion; Anything else: Recursive ; Extensions = Single or multiple extensions, separated by ";" or "|". "*." will be auto-affixed if missing ; Excluded_Paths = Single or multiple paths, separated by "|". No automatic wildcard embracing! ; Excluded_Files = Single or multiple files, separated by "|". No automatic wildcard embracing! ; Excluded files will be REMOVED from all other found files! ; Included_Files = Single or multiple files, separated by "|". No automatic wildcard embracing! ; ONLY these files will be displayed (minus Excluded_Files)! ; Section names = Only use the letters [a-zA-Z0-9] and/or "_", "-"! ; The order of the sections (apart from "General") matters! [Windows] Paths=%WINDIR% Recursive=0 Extensions=exe Excluded_Files=bfsvc.exe ;[System32] ;Paths=%WINDIR%\System32 ;Recursive=1 ;Extensions=exe ;Excluded_Paths=\wbem|\oobe ;Excluded_Files=dxdiag.exe|eventvwr.exe ;Included_Files=calc.exe|cleanmgr.exe|control.exe|dxdiag.exe|eventvwr.exe|msinfo32.exe|mspaint.exe|notepad.exe|perfmon.exe ;[Tools] ;Paths=D:\Tools\@Shortcuts ;Recursive=0 ;Extensions=*.lnk ;[User_Tools] ;Paths=D:\Users\%USERNAME%\Tools\@Shortcuts ;Recursive=0 ;Extensions=*.lnk >>>; if (exists($iniFile) != 1) { writefile($iniFile, $iniContent, , "tu"); } $sections = formatlist(getsectionlist(, $iniFile), "f", , "!General"); $windowWidth = getkey("Window_Width", "General", $iniFile); $windowHeight = getkey("Window_Height", "General", $iniFile); $removeLnkExtension = getkey("Remove_Lnk_Extension", "General", $iniFile); $removeExeExtension = getkey("Remove_Exe_Extension", "General", $iniFile); $defaultExtensions = getkey("Default_Extensions", "General", $iniFile); $useSeparators = getkey("Use_Separators", "General", $iniFile); $separatorAbove = getkey("Separator_Above", "General", $iniFile); $seperatorString = getkey("Separator_String", "General", $iniFile); $seperatorIcon = getkey("Seperator_Icon", "General", $iniFile); // Default values if necessary $windowWidth = ($windowWidth) ? $windowWidth : 400; $windowHeight = ($windowHeight) ? $windowHeight : 700; $defaultExtensions = ($defaultExtensions) ? $defaultExtensions : "*.exe;*.lnk"; $seperatorIcon = ($seperatorIcon) ? $seperatorIcon : ":queue"; $seperatorString = ($seperatorString) ? "$seperatorString||$seperatorIcon" : strrepeat("-", 50) . "^||$seperatorIcon"; $seperator = ($useSeparators) ? . $seperatorString . : ; $found = ""; foreach($section, $sections, , "e") { $paths = eval(quote(getkey("Paths", $section, $iniFile))); $recursive = getkey("Recursive", $section, $iniFile); $extensions = getkey("Extensions", $section, $iniFile); $excPaths = eval(quote(getkey("Excluded_Paths", $section, $iniFile))); $excFiles = getkey("Excluded_Files", $section, $iniFile); $incFiles = getkey("Included_Files", $section, $iniFile); // Non-recursive by default $recursive = (!$recursive) ? "/n" : ""; // Handle extensions incl. auto-wildcarding $extensions = ($extensions) ? $extensions : $defaultExtensions; if (strpos($extensions, "*") == -1) { $extensions = trim(regexreplace($extensions, "^|(;|\|)", ";*."), ";"); } // Check multi-location path(s) existence $multiPaths = ""; foreach($path, $paths, "|", "e") { if (exists($path) == 2) { $multiPaths .= ($multiPaths ? "|" . $path : $path); } } // Set exclude flags $excPathsFlag = ($excPaths) ? " /excl=$excPaths" : " "; $excFilesFlag = ($excFiles) ? " /exclfile=$excFiles" : " "; // Find item(s) $items = quicksearch("$extensions $recursive" . $excPathsFlag . $excFilesFlag, $multiPaths, , "s"); // Include file(s) - Only these items will be listed (minus $excFiles)! if ($incFiles) { $items = formatlist($items, "f", , replace($incFiles, "|", ), "f"); } // Build the entry list if ($items) { if ($separatorAbove) { $found .= ((strpos($seperatorString, "#SectionName#") != -1) ? replace($seperator, "#SectionName#", $section) : $seperator) . $items; } else { $found .= $items . ((strpos($seperatorString, "#SectionName#") != -1) ? replace($seperator, "#SectionName#", $section) : $seperator); } } } if (!$found) { status "No items found, aborted!", "8B4513", "stop"; end true; } // Remove empty lines $found = formatlist($found, "e", ); // Build "Caption|Data|Icon" $found = regexreplace($found, "^(.+\\)(.*?)(?=\r?\n|$)", "$2|$1$2|$1$2"); // Remove .lnk in captions if ($removeLnkExtension) { $found = regexreplace($found, "^(.+?)(\.lnk)\|", "$1|"); } if ($removeExeExtension) { $found = regexreplace($found, "^(.+?)(\.exe)\|", "$1|"); } // Selection window $selected = inputselect("", $found, , 1+32+64+1024, , $windowWidth, $windowHeight); if ($selected == "") { status "No valid entry selected, aborted!", "8B4513", "stop"; end true; } // Execute open $selected; /* @Changelog: v0.3 + Added "Remove_Exe_Extension=" setting. Default = 1 * Changed default value for "Separator_String=" to: "---------- [#SectionName#] ----------" "#SectionName#" will be replaced with the belonging .ini section name... + Added "Separator_Above=" setting. Default = 1. When using 0, the separator lines comes after the entries v0.2 ! Eval() was necessary to resolve environment variables from inside the .ini file v0.1 • Initial release */