ProxyCmdExecutorWMIC
This commit is contained in:
@@ -15,6 +15,11 @@ namespace VAR.Toolbox.Code
|
||||
string configSqlServer = config.Substring("SqlServer:".Length);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
27
VAR.Toolbox/Code/ProxyCmdExecutorWMIC.cs
Normal file
27
VAR.Toolbox/Code/ProxyCmdExecutorWMIC.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Code\HexUtils.cs" />
|
||||
<Compile Include="Code\ProxyCmdExecutorWMIC.cs" />
|
||||
<Compile Include="Code\TextCoderBase64Utf8.cs" />
|
||||
<Compile Include="Code\TextCoderBase64Ascii.cs" />
|
||||
<Compile Include="Code\DirectShow\CameraControlProperty.cs" />
|
||||
|
||||
Reference in New Issue
Block a user