1
I’m trying to make a C# Application Console with some command options to run in Git ssh. Git’s ssh executable is in the following path: C:/Program Files (x86)/Git/bin/sh.exe, and I’m trying to run a simple command as follows:
string pathGit = "\"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login";
string commandString = "git";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = pathGit;
startInfo.Arguments = commandString;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
process.StartInfo = startInfo;
process.Start();
The "-login" in front of the path is required to actually enter the Git console, but it’s basically the one that’s causing the error. I did a lot of research, but I couldn’t find a solution.
Wouldn’t it be right to pass the
--login
instartInfo.Arguments
? That is to say:string commandString = "--login git"
.– Ismael
Really, this way he understands and enters the console. Is there a possibility that I can continue using this process to give other commands from now on? (I believe this would be another question on the site, am I right? rs).
– Sérgio Torres
Of course you can continue passing other parameters. That’s why it’s called Arguments :p
– Ismael