ProxyCmdExecutorWMIC

This commit is contained in:
2018-11-02 13:32:09 +01:00
parent abaa7e5e88
commit 24b49af7f6
3 changed files with 33 additions and 0 deletions

View File

@@ -15,6 +15,11 @@ namespace VAR.Toolbox.Code
string configSqlServer = config.Substring("SqlServer:".Length); string configSqlServer = config.Substring("SqlServer:".Length);
return new ProxyCmdExecutorThroughSQLServer(configSqlServer); return new ProxyCmdExecutorThroughSQLServer(configSqlServer);
} }
if (config.StartsWith("WMIC:"))
{
string configWMIC = config.Substring("WMIC:".Length);
return new ProxyCmdExecutorWMIC(configWMIC);
}
throw new NotImplementedException(string.Format("Cant create IProxyCmdExecutor with this config: {0}", config)); throw new NotImplementedException(string.Format("Cant create IProxyCmdExecutor with this config: {0}", config));
} }
} }

View File

@@ -0,0 +1,27 @@
using System.Diagnostics;
namespace VAR.Toolbox.Code
{
internal class ProxyCmdExecutorWMIC : IProxyCmdExecutor
{
private string _configWMIC;
public ProxyCmdExecutorWMIC(string configWMIC)
{
_configWMIC = configWMIC;
}
public bool ExecuteCmd(string cmd, IOutputHandler outputHandler)
{
string parameters = string.Format(" /node:\"{0}\" process call create \"cmd.exe /c \\\"{1}\\\"\"", _configWMIC.Replace("\"", "\\\""), cmd.Replace("\"", "\\\""));
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "WMIC";
process.StartInfo.Arguments = parameters;
process.StartInfo.CreateNoWindow = true;
process.Start();
return true;
}
}
}

View File

@@ -54,6 +54,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Code\HexUtils.cs" /> <Compile Include="Code\HexUtils.cs" />
<Compile Include="Code\ProxyCmdExecutorWMIC.cs" />
<Compile Include="Code\TextCoderBase64Utf8.cs" /> <Compile Include="Code\TextCoderBase64Utf8.cs" />
<Compile Include="Code\TextCoderBase64Ascii.cs" /> <Compile Include="Code\TextCoderBase64Ascii.cs" />
<Compile Include="Code\DirectShow\CameraControlProperty.cs" /> <Compile Include="Code\DirectShow\CameraControlProperty.cs" />