I'am attempting to develop a script that dynamically executes files based on their extensions, bypassing the default file type associations. For example, I want to open *.ZIP files with 'FBNeoX' (game ROM emulator software) instead of the standard 'WinRar' as configured in File Type Settings et. al.. The goal is to trigger specific applications to open files with certain extensions through a custom script when the file is focused (separate from File Type Settings.)
I've experimented with AI-generated scripts and implemented multiple conditional statements (if/else), but I keep encountering errors. I'am wondering if it's feasible to achieve this functionality within MultiCommander via scripting. Is such dynamic extension-based execution achievable in MultiCommander, and if so, what would be the recommended approach ?
This doesn't work (one of many !)::
// SmartOpen — Ctrl+F9
// Requires MultiScript modules: Str (String Tools), Path (Path Tools)
@var $f = GetSourceFocusPath();
if ($f == "") { return; }
if (FS.IsFolder($f) == 1) { return; }
// extension (lowercase, without dot)
@var $ext = Path.GetFileExtension($f);   // requires Path module
$ext = Str.LCase($ext);                  // requires Str module
@var $app = "";
// MASM
if      ($ext == "asm") { $app = "D:\\masm32\\qeditor.exe"; }
// Text-like (Markdown intentionally NOT included)
elseif  ($ext == "txt" || $ext == "ini" || $ext == "log" || $ext == "ahk" ||
         $ext == "mtxt"|| $ext == "vbs" || $ext == "conf"|| $ext == "cpp" ||
         $ext == "h"   || $ext == "rc"  || $ext == "nfo" || $ext == "info"||
         $ext == "ps1" || $ext == "xml" || $ext == "jsee"|| $ext == "cfg") {
  $app = "C:\\Users\\dell\\Downloads\\thumbstick\\notepad2-4-2-25-en-win\\Notepad2.exe";
}
// Pictures
elseif  ($ext == "jpg" || $ext == "jpeg"|| $ext == "jpe" || $ext == "png" ||
         $ext == "gif" || $ext == "bmp" || $ext == "tif" || $ext == "tiff"||
         $ext == "webp"|| $ext == "jfif"|| $ext == "psd") {
  $app = "D:\\Download\\FreeVimager\\FreeVimager.exe";
}
// E-books
elseif  ($ext == "pdf" || $ext == "epub"|| $ext == "djvu"|| $ext == "mobi" ||
         $ext == "fb2" || $ext == "cb7" || $ext == "cbr" || $ext == "cbt"  ||
         $ext == "cbz" || $ext == "prc" || $ext == "azw" || $ext == "chm") {
  $app = "C:\\Users\\dell\\Documents\\SumatraALLOld\\SumatraPDF-3.2-64.exe";
}
// Cursors / Icons
elseif  ($ext == "cur" || $ext == "ani") {
  $app = "D:\\Download\\RealWorld Cursor Editor\\RWCursorEditor.exe";
}
// PowerPoint
elseif  ($ext == "pptx"|| $ext == "ppt" || $ext == "pps" || $ext == "ppsx") {
  $app = "C:\\Program Files\\Microsoft Office\\root\\Office16\\POWERPNT.EXE";
}
// Visual Studio
elseif  ($ext == "sln") {
  $app = "D:\\Download\\VS 19 CE\\Common7\\IDE\\devenv.exe";
}
// Sega Genesis / Mega-Drive (.md intentionally included)
elseif  ($ext == "gen" || $ext == "smd" || $ext == "bin" || $ext == "md") {
  $app = "D:\\Games\\Genesis ROMs\\Gens-2.11\\Gens 211 (Hacked) (USETHIS).qalnk";
}
// SNES
elseif  ($ext == "sfc" || $ext == "smc" || $ext == "fig") {
  $app = "D:\\Games\\Genesis ROMs\\SNES 9x Emulator\\SNES 9x x64 Emulator.qalnk";
}
// NES
elseif  ($ext == "nes") {
  $app = "D:\\Games\\Genesis ROMs\\Nestopia140bin\\Nestopia NES Emulator.qalnk";
}
// FB Neo ZIP ROMs
elseif  ($ext == "zip") {
  $app = "C:\\Users\\dell\\Documents\\FB Neo x64 (DO NOT DELETE)\\fbneo64.exe";
}
// Launch (ShellExecute works for .exe and .qalnk)
if ($app == "") {
  MC.ShellExecute FILE="{$f}" SHOW=1;
} else {
  MC.ShellExecute FILE="{$app}" PARAMS="\"{$f}\"" SHOW=1;
}
OR THIS::
// SmartOpen (Ctrl+F9) — Multi Commander v15.6
// Opens the focused file in a designated app by extension
@var $item = GetSourceFocusPath();
if ($item == "") { return; }         // nothing focused
if (FS.IsFolder($item) == 1) { return; }  // ignore folders
@var $ext = Str.LCase(Path.GetFileExt($item));  // extension without dot (lowercase)
@var $app = "";
// Text-like
if ( $ext == "txt"  || $ext == "ini" || $ext == "log" || $ext == "ahk" ||
     $ext == "mtxt" || $ext == "vbs" || $ext == "conf"|| $ext == "cpp" ||
     $ext == "h"    || $ext == "rc"  || $ext == "asm" || $ext == "nfo" ||
     $ext == "info" || $ext == "ps1" || $ext == "md"  || $ext == "xml" ||
     $ext == "jsee" || $ext == "cfg" ) {
  $app = "C:\Users\dell\Downloads\thumbstick\notepad2-4-2-25-en-win\Notepad2.exe";
// Pictures
} else if ( $ext == "jpg" || $ext == "png"  || $ext == "jpeg" || $ext == "gif" ||
            $ext == "webp"|| $ext == "jpe"  || $ext == "jfif" || $ext == "psd" ||
            $ext == "bmp" || $ext == "tif"  || $ext == "tiff" ) {
  $app = "D:\Download\FreeVimager\FreeVimager.exe";
// e-Books
} else if ( $ext == "pdf" || $ext == "epub" || $ext == "djvu" || $ext == "mobi" ||
            $ext == "fb2" || $ext == "cb7"  || $ext == "cbr"  || $ext == "cbt"  ||
            $ext == "cbz" || $ext == "prc"  || $ext == "azw"  || $ext == "chm" ) {
  $app = "C:\Users\dell\Documents\SumatraALLOld\SumatraPDF-3.2-64.exe";
// Cursors / Icons
} else if ( $ext == "cur" || $ext == "ani" ) {
  $app = "D:\Download\RealWorld Cursor Editor\RWCursorEditor.exe";
// PowerPoint
} else if ($ext == "pptx") {
  $app = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.EXE";
// Visual Studio Solutions
} else if ($ext == "sln") {
  $app = "D:\Download\VS 19 CE\Common7\IDE\devenv.exe";
} else {
  // No handler for this extension
  return;
}
// Launch the app with the focused file as argument
App.Run CMD="$app" PARAMS="\"$item\"" SHOW=1 WAIT=0;
P.S: *.QALNK filetypes are just special types of shortcuts I use to Run as Admin, effectively bypassing UAC Prompts (using the "Quick Admin" app.) Apparently you need to use ShellExecute to open *.QALNK files in MC & stuff…