If I run following command in console, it will succeed:
"C:\Users\myAccount.Unit\Favorites\Downloads\fiji.app (1)\fiji.exe" -macro "C:\Users\myAccount.Unit\Favorites\Downloads\fiji.app (1)\macros\FFTBatch.ijm" C:\Users\myAccount.Unit\Documents\Untitled001\
where
"C:\Users\myAccount.Unit\Favorites\Downloads\fiji.app (1)\fiji.exe"
is the application file,
"C:\Users\myAccount.Unit\Favorites\Downloads\fiji.app (1)\macros\FFTBatch.ijm"
is the macro file that gets executed,
and C:\Users\myAccount.Unit\Documents\Untitled001\
is the images processed by the previous macro.
However, when I use C# to do this job, it failed (meaning no response at all). Following is the relevant code:
string _fijiExeFile = "C:\\Users\\myAccount.Unit\\Favorites\\Downloads\\fiji.app (1)\\fiji.exe";
string _ijmFile = "C:\\Users\\myAccount.Unit\\Favorites\\Downloads\\fiji.app (1)\\macros\\FFTBatch.ijm";
string _inputDir = "C:\\Users\\myAccount.Unit\\Documents\\Untitled001\\";
string fijiCmdText = string.Format("/C \"{0}\" -macro \"{1}\" {2}", _fijiExeFile, _ijmFile, _inputDir);
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = fijiCmdText;
process.StartInfo = startInfo;
process.Start();
_processOn = true;
process.WaitForExit();
ret = 1;
}
catch (Exception ex)
{
ret = 0;
}
(The path are actually obtained from the UI, I am just posting what it is.)
This is what I observed for fijiCmdText
when I step in:
"/C \"C:\\Users\\myAccount.Unit\\Favorites\\Downloads\\fiji.app (1)\\fiji.exe\" -macro \"C:\\Users\\myAccount.Unit\\Favorites\\Downloads\\fiji.app (1)\\macros\\FFTBatch.ijm\" C:\\Users\\myAccount.Unit\\Documents\\Untitled001\\"
If I only use
string fijiCmdText = string.Format("/C \"{0}\"", _fijiExeFile);
It does launch the .exe application, however if I intended to add the macro file path, it fails.
Any thing wrong here?