LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

system() call not working

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?

0 Kudos
Message 1 of 2
(2,953 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,945 Views)