Loading Igor from a Batch File


I'd like to create a windows batch file to do two things:
1) Launch Igor and open a particular experiment file.
2) Run a command in this experiment file.

So far I have this:
"C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" "E:\Documents\Igor_Experiments\Experiment.pxp" "C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" /X "runFunction()"

When I run this file it launches Igor and opens the specified experiment but it doesn't run the function. Once I close the experiment file it immediately opens another instance of Igor and tries to run the command but can't because that command does not exist in the blank experiment file. Is there a way to get this to work? I know that I could put the command in the procedure window before any of the functions and it would be run when Igor launches but ideally I'd like to have two batch files for the users of my program to work with: one that would do what I've talked about above and one that would only open the experiment without running the function.

Any ideas are greatly appreciated!
Thank you!
What you describe is how batch files work and isn't due to Igor. The batch processor waits until one command is complete (and the program it calls has returned) before it moves on to execute the next line. Take a look at https://stackoverflow.com/questions/1449188/running-windows-batch-file-… for a solution that may work for you.

An alternative approach would be to put runFunction() at the top of the built-in procedure window, as you mentioned. You could modify your runFunction() code a bit to test whether a key is pressed (eg. the Alt/Option key) and if it is then bail out. Otherwise runFunction() does whatever it normally does.
Use the start command in the batch file:
<br />
start /b "" "C:\Program Files\Wavemetrics\Igor Pro 7 Folder\IgorBinaries_x64\Igor64.exe" /X "make test"<br />
ping /n 10 > nul<br />
start /b "" "C:\Program Files\Wavemetrics\Igor Pro 7 Folder\IgorBinaries_x64\Igor64.exe" /X "display test"<br />

The ping command is used to give Igor some time to start up. The number of pings (10) can be adjusted to your needs.


Note: Maybe this issue with batch files could be added to the manual in section "Calling Igor from Scripts"?
Thanks for the suggestions! I've added the start command to the batch file and that is working.

Thank you!
A cleaner alternative to "ping /n 10 > nul" is the "timeout" command (works on Windows 7 at least):

start "C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" "E:\Documents\Igor_Experiments\Experiment.pxp" & timeout/t 20 "C:\Program Files (x86)\Wavemetrics\Igor Pro Folder\Igor64.exe" /X "runFunction()"
On older systems it would be sleep. I wanted to avoid conditional batch files. ping works on any windows version (>3.1, I think).