Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executing PowerShell code at the API level
#9
Another way. Not tested with PowerShell dlls.
 
Code:
Copy      Help
using System.Runtime.Loader;

AssemblyLoadContext.Default.Resolving += (o, e) => {
    //print.it(e.Name);
    var path = $@"C:\Program Files\PowerShell\7\{e.Name}.dll";
    if (filesystem.exists(path)) return AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
    return null;
};

It will not copy dlls to the exe folder, but will use dlls in the PowerShell folder.


Messages In This Thread
RE: Executing PowerShell code at the API level - by Gintaras - 03-28-2024, 09:01 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)