mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Adding some exectuable awareness
This commit is contained in:
parent
e4add2570f
commit
cca916c515
@ -428,8 +428,48 @@ namespace DisplayMagician.Processes
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static bool TryExecute(string executable, string arguments, out Process process, ProcessPriorityClass priorityClass = ProcessPriorityClass.Normal, int maxWaitMs = 1000)
|
private static bool TryExecute(string executable, string arguments, out Process process, ProcessPriorityClass priorityClass = ProcessPriorityClass.Normal, int maxWaitMs = 1000)
|
||||||
{
|
{
|
||||||
StringBuilder outputBuilder = new StringBuilder();
|
//StringBuilder outputBuilder = new StringBuilder();
|
||||||
using (Process processCreated = new Process { StartInfo = new ProcessStartInfo(executable, arguments) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = false} })
|
|
||||||
|
bool _isFile = false;
|
||||||
|
bool _isExe = false;
|
||||||
|
if (File.Exists(executable))
|
||||||
|
{
|
||||||
|
_isFile = true;
|
||||||
|
if (Path.GetExtension(executable).Equals(".exe",StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
Path.GetExtension(executable).Equals(".com", StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
Path.GetExtension(executable).Equals(".msi", StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
Path.GetExtension(executable).Equals(".bat", StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
Path.GetExtension(executable).Equals(".cmd", StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
Path.GetExtension(executable).Equals(".ps1", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
_isExe = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessStartInfo psi;
|
||||||
|
if (_isFile && _isExe)
|
||||||
|
{
|
||||||
|
// Is exe file
|
||||||
|
psi = new ProcessStartInfo(executable, arguments)
|
||||||
|
{
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = false,
|
||||||
|
RedirectStandardOutput = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Isn't a file (somethign like a url), or is a file but isn't an executable
|
||||||
|
psi = new ProcessStartInfo(executable, arguments)
|
||||||
|
{
|
||||||
|
UseShellExecute = true,
|
||||||
|
Verb = "Open",
|
||||||
|
CreateNoWindow = false,
|
||||||
|
RedirectStandardOutput = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Process processCreated = new Process { StartInfo = psi })
|
||||||
{
|
{
|
||||||
/*if (redirectInputOutput)
|
/*if (redirectInputOutput)
|
||||||
{
|
{
|
||||||
@ -440,6 +480,9 @@ namespace DisplayMagician.Processes
|
|||||||
// Attach the event handler for OutputDataReceived before starting the process.
|
// Attach the event handler for OutputDataReceived before starting the process.
|
||||||
process.OutputDataReceived += (sender, e) => outputBuilder.Append(e.Data);
|
process.OutputDataReceived += (sender, e) => outputBuilder.Append(e.Data);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
processCreated.Start();
|
processCreated.Start();
|
||||||
|
|
||||||
/*if (redirectInputOutput)
|
/*if (redirectInputOutput)
|
||||||
|
@ -26,8 +26,8 @@ using System.Resources;
|
|||||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("2.1.0.285")]
|
[assembly: AssemblyVersion("2.1.0.286")]
|
||||||
[assembly: AssemblyFileVersion("2.1.0.285")]
|
[assembly: AssemblyFileVersion("2.1.0.286")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user