Use start in Invoke-Item to open items on Windows

Since `UseShellExecute` cannot be used.
This commit is contained in:
Andrew Schwartzmeyer
2016-07-08 13:48:36 -07:00
committed by Andrew Schwartzmeyer
parent afc1d8a459
commit ef2ba40ca7
@@ -1333,14 +1333,18 @@ namespace Microsoft.PowerShell.Commands
{
System.Diagnostics.Process invokeProcess = new System.Diagnostics.Process();
invokeProcess.StartInfo.UseShellExecute = false;
if (Platform.IsWindows)
{
System.Diagnostics.Process.Start(path);
}
invokeProcess.StartInfo.FileName = "cmd.exe";
// start is very picky: the "optional" TITLE as the first argument should always be included, otherwise it can silently fail
invokeProcess.StartInfo.Arguments = string.Format(@"/c ""start /b """" ""{0}""""", path);
}
else if (Platform.IsOSX) {
invokeProcess.StartInfo.FileName = "open";
invokeProcess.StartInfo.Arguments = path;
}
}
else if (Platform.IsLinux) {
invokeProcess.StartInfo.FileName = "xdg-open";
invokeProcess.StartInfo.Arguments = path;