Skip to content

Commit

Permalink
Force full path exename when calling CreateProcess from cmd. Fix for #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Grignoli committed Jan 13, 2020
1 parent 967751e commit 0a565cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gsudo.Tests/CmdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,17 @@ public void Cmd_UnexistentAppTest()
p.WaitForExit();
Assert.AreNotEqual(0, p.ExitCode);
}

[TestMethod]
public void Cmd_BatchFileWithoutExtensionTest()
{
File.WriteAllText("HelloWorld.bat", "@echo Hello");

var p = new TestProcess("gsudo.exe", "HelloWorld");
p.WaitForExit();
Assert.AreEqual(string.Empty, p.GetStdErr());
Assert.AreEqual("Hello\r\n", p.GetStdOut());
Assert.AreEqual(0, p.ExitCode);
}
}
}
1 change: 1 addition & 0 deletions src/gsudo/Helpers/ArgumentsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ internal static string[] AugmentCommand(string[] args)
}
else
{
args[0] = exename; // Batch files not started by create process if no extension is specified.
return args;
}
}
Expand Down

0 comments on commit 0a565cf

Please sign in to comment.