Merge pull request #321 from jeacott1/hidewindow

Add a new `hidewindow` option to suppress windows popup on legacy platforms
pull/331/head
Oleg Nenashev 2019-08-17 00:44:38 +02:00 committed by GitHub
commit 831c7fbb7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 3 deletions

View File

@ -453,7 +453,8 @@ namespace winsw
priority: _descriptor.Priority,
callback: processCompletionCallback,
logHandler: logHandler,
redirectStdin: redirectStdin);
redirectStdin: redirectStdin,
hideWindow: _descriptor.HideWindow);
}
public static int Main(string[] args)

View File

@ -18,6 +18,7 @@ namespace winsw.Configuration
public string Caption { get { return null; } }
public string Description { get { return null; } }
public string Executable { get { return null; } }
public bool HideWindow { get { return false; } }
public string ExecutablePath
{

View File

@ -14,6 +14,7 @@ namespace winsw.Configuration
string Description { get; }
string Executable { get; }
string ExecutablePath { get; }
bool HideWindow { get; }
// Installation
bool AllowServiceAcountLogonRight { get; }

View File

@ -175,6 +175,13 @@ namespace winsw
}
}
public bool HideWindow
{
get {
return SingleBoolElement("hidewindow", Defaults.HideWindow);
}
}
/// <summary>
/// Optionally specify a different Path to an executable to shutdown the service.
/// </summary>

View File

@ -132,13 +132,13 @@ namespace winsw.Util
/// <param name="logHandler">Log handler. If enabled, logs will be redirected to the process and then reported</param>
/// <param name="redirectStdin">Redirect standard input</param>
public static void StartProcessAndCallbackForExit(Process processToStart, String executable = null, string arguments = null, Dictionary<string, string> envVars = null,
string workingDirectory = null, ProcessPriorityClass? priority = null, ProcessCompletionCallback callback = null, bool redirectStdin = true, LogHandler logHandler = null)
string workingDirectory = null, ProcessPriorityClass? priority = null, ProcessCompletionCallback callback = null, bool redirectStdin = true, LogHandler logHandler = null, bool hideWindow = false)
{
var ps = processToStart.StartInfo;
ps.FileName = executable ?? ps.FileName;
ps.Arguments = arguments ?? ps.Arguments;
ps.WorkingDirectory = workingDirectory ?? ps.WorkingDirectory;
ps.CreateNoWindow = false;
ps.CreateNoWindow = hideWindow;
ps.UseShellExecute = false;
ps.RedirectStandardInput = redirectStdin;
ps.RedirectStandardOutput = logHandler != null;