chrome.exe
과 함께 WHERE 명령을 인수로 사용하십시오. 그러면 쉘이로드 할 실행 파일의 경로를 알려줍니다.
명령의 출력을 다시 읽으면됩니다.
현재 버전과 마찬가지로 실행 파일이 시스템 PATH에 있다고 가정합니다.
다음은 사용자 요구에 맞출 수있는 몇 가지 코드입니다. 그것은 본질적으로 WHERE 명령을 래핑합니다 (도중에 실행 파일이므로 WHERE WHERE
은 경로를 표시합니다).
using System;
using System.Diagnostics;
public sealed class WhereWrapper
{
private static string _exePath = null;
public static int Main(string[] args) {
int exitCode;
string exeToFind = args.Length > 0 ? args[0] : "WHERE";
Process whereCommand = new Process();
whereCommand.OutputDataReceived += Where_OutputDataReceived;
whereCommand.StartInfo.FileName = "WHERE";
whereCommand.StartInfo.Arguments = exeToFind;
whereCommand.StartInfo.UseShellExecute = false;
whereCommand.StartInfo.CreateNoWindow = true;
whereCommand.StartInfo.RedirectStandardOutput = true;
whereCommand.StartInfo.RedirectStandardError = true;
try {
whereCommand.Start();
whereCommand.BeginOutputReadLine();
whereCommand.BeginErrorReadLine();
whereCommand.WaitForExit();
exitCode = whereCommand.ExitCode;
} catch (Exception ex) {
exitCode = 1;
Console.WriteLine(ex.Message);
} finally {
whereCommand.Close();
}
Console.WriteLine("The path to {0} is {1}", exeToFind, _exePath ?? "{not found}");
return exitCode;
}
private static void Where_OutputDataReceived(object sender, DataReceivedEventArgs args) {
if (args.Data != null) {
_exePath = args.Data;
}
}
}
이 문제를 해결 했습니까? – harpo