Unity 运行Exe应用程序
private static int ExecuteBat(string path, string arg)
{
int code = 0;
System.Diagnostics.Process proc = null;
var currentWorkDirectory Directory.GetCurrentDirectory();
try
{
Directory.SetCurrentDirectory(Path.GetDirectoName(path));
proc = new System.Diagnostics.Process();
if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
{
proc.StartInfo.FileName = path;
proc.StartInfo.Arguments = arg;
}
else
{
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = path + " " arg;
}
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.WaitForExit();
code = proc.ExitCode;
proc.Close();
return code;
}
catch (Exception ex)
{
Debug.LogException(ex);
}
finally
{
Directory.SetCurrentDirectory(currentWorkDireory);
}
return 1;
}
本文标题:Unity 运行Exe应用程序
本文链接:https://www.haomeiwen.com/subject/bfrgirtx.html
网友评论