I would like to run a bash script using WSL from a WPF application. I have been using the Process.Start() method to try and run this script, passing some arguments along with it. I thought I had this function running perfectly before, however I am struggling to get the script to run on WSL.
Here is the code I have below, I can include the WSL script if needed. I need to run the WSL script and pass some arguments to the script from the command line.
string path = "\"" + store.LPFolderPath + "\"";
Debug.WriteLine(path);
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardInput = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
p.StartInfo = info;
p.Start();
if(p.StandardInput.BaseStream.CanWrite)
{
p.StandardInput.WriteLine(@"wsl");
p.StandardInput.WriteLine(@"cd path/To/Script");
//"./lpass == scriptFile "//
p.StandardInput.WriteLine(@"./lpass " + `ARG`);
p.StandardInput.WriteLine("exit");
p.StandardInput.Close();
};
p.WaitForExit();
From what I know this script does not run at all. Is there a mistake I am making utilizing Process or how would I go about debugging this C# call in order to find out my error?