Skip to content

Instantly share code, notes, and snippets.

@gpoul
Created April 17, 2017 11:19
Show Gist options
  • Save gpoul/45148076fc0ef84e72fe17eb3d31fa68 to your computer and use it in GitHub Desktop.
Save gpoul/45148076fc0ef84e72fe17eb3d31fa68 to your computer and use it in GitHub Desktop.
Shim for the WSL Ubuntu ledger binary from Win32
using System.Diagnostics;
using System;
class Program
{
static void Main(string[] args)
{
LaunchCommandLineApp(args);
}
static void LaunchCommandLineApp(string[] args)
{
// Fix the file path provided to make sure it is found
string ledgerArgs = System.String.Join(" ", args);
ledgerArgs = ledgerArgs.Replace("\\", "/");
ledgerArgs = ledgerArgs.Replace("C:/", "/mnt/c/");
// Call ledger through bash.exe in WSL
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "bash.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-c 'ledger " + ledgerArgs + "'";
try
{
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// TBD
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment