mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Adds noShellExecute to IProcessExecutor
This commit is contained in:
@@ -125,7 +125,8 @@ namespace Tgstation.Server.Host.Components.Byond
|
||||
{
|
||||
//always install it, it's pretty fast and will do better redundancy checking than us
|
||||
var rbdx = ioManager.ConcatPath(path, ByondDXDir);
|
||||
using (var p = processExecutor.LaunchProcess(ioManager.ConcatPath(rbdx, "DXSETUP.exe"), rbdx, "/silent"))
|
||||
//noShellExecute because we aren't doing runas shennanigans
|
||||
using (var p = processExecutor.LaunchProcess(ioManager.ConcatPath(rbdx, "DXSETUP.exe"), rbdx, "/silent", noShellExecute: true))
|
||||
{
|
||||
int exitCode;
|
||||
using (cancellationToken.Register(() => p.Terminate()))
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
/// <param name="workingDirectory">The working directory for the <see cref="IProcess"/></param>
|
||||
/// <param name="readOutput">If standard output should be read</param>
|
||||
/// <param name="readError">If standard error should be read</param>
|
||||
/// <param name="noShellExecute">If shell execute should not be used. Ignored if <paramref name="readError"/> or <paramref name="readOutput"/> are set</param>
|
||||
/// <returns>A new <see cref="IProcess"/></returns>
|
||||
IProcess LaunchProcess(string fileName, string workingDirectory, string arguments = null, bool readOutput = false, bool readError = false);
|
||||
IProcess LaunchProcess(string fileName, string workingDirectory, string arguments = null, bool readOutput = false, bool readError = false, bool noShellExecute = false);
|
||||
|
||||
/// <summary>
|
||||
/// Get a <see cref="IProcess"/> by <paramref name="id"/>
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.Core
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IProcess LaunchProcess(string fileName, string workingDirectory, string arguments, bool readOutput, bool readError)
|
||||
public IProcess LaunchProcess(string fileName, string workingDirectory, string arguments, bool readOutput, bool readError, bool noShellExecute)
|
||||
{
|
||||
logger.LogDebug("Launching process in {0}: {1} {2}", workingDirectory, fileName, arguments);
|
||||
var handle = new System.Diagnostics.Process();
|
||||
@@ -62,11 +62,12 @@ namespace Tgstation.Server.Host.Core
|
||||
handle.StartInfo.FileName = fileName;
|
||||
handle.StartInfo.Arguments = arguments;
|
||||
handle.StartInfo.WorkingDirectory = workingDirectory;
|
||||
|
||||
|
||||
handle.StartInfo.UseShellExecute = !(noShellExecute || readOutput || readError);
|
||||
|
||||
StringBuilder outputStringBuilder = null, errorStringBuilder = null, combinedStringBuilder = null;
|
||||
if (readOutput || readError)
|
||||
{
|
||||
handle.StartInfo.UseShellExecute = false;
|
||||
combinedStringBuilder = new StringBuilder();
|
||||
if (readOutput)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user