09-13-2010 09:13 PM
I have a single line batch file that calls an ATMEL GUI via command line params. The batch file works fine. However, trying to call the batch file in a system() or LaunchExe() call does not. I am stumped. I have tried all of the following variants of calling it programmatically--none of which produce an output log file and all of which terminate almost immediately. When I run the batch file manually via a command window, it takes about 20-30 seconds to run. Any ideas?
1) err = system("C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\pgmall.bat");
2)err = system("C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\sam-ba.exe \\usb\\ARM0 AT91SAM9G20-EK pgmall.tcl > pgm_all.log 2>&1");
3) err =system("cmd.exe C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\pgm_all.bat");
4) err = LaunchExecutableEx ("C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\pgm_all.bat", LE_SHOWMINIMIZED, &g_bat);
5) err = LaunchExecutableEx ("C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\usb\\ARM0 AT91SAM9G20-EK pgmall.tcl > pgm_all.log 2>&1", LE_SHOWMINIMIZED, &g_bat);
Other suggestions?
09-14-2010 12:20 AM
One possible problem can be the embedded spaces in the pathname: in this case Windows requires the command to be enclosed in quotes. Try this:
err = system("\"C:\\Program Files\\ATMEL Corporation\\SAM-BA v2.10\\pgmall.bat\"");
Another possibility is that prepending a "cmd /c" be required in some case, depending on the content of the batch file or for redirection.