LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch an external Batch file from LabVIEW

I realize this question has been asked before, but all the solutions I've found in the archive are either for a later version of LabVIEW than what I have or do not work.
 
I need to issue a call to a customer's Batch file via a button in LabVIEW. The LabVIEW program must call the external file, and the execution must behave just like manually launching the batch file.
 
I searched though the archive and found a 'launch application 6.0.vi' in the archives, and it appeared to work. I placed it in my code, tested, and saw nothing out of the ordinary. However, after the customer recieved and tried to run the software, the execution failed. The batch file runs correctly when it is manually executed, and it runs correctly via Windows task manager. I have tried modifing the 'launch application 6.0.vi' program, but it still does not appear to work.

Message Edited by BobChuck on 12-14-2006 01:52 PM

Message Edited by BobChuck on 12-14-2006 01:53 PM

Download All
0 Kudos
Message 1 of 10
(8,580 Views)

OK, I got it to work by getting rid of "start" in the input command. Also, you should add code to put quotes around the filename. It may work on your computer, then your customer gives it a path that has a space and windows will return an error. I don't have LV 6.0 so I can't save it for you, but here's a picture.

Message Edited by Marc A on 12-14-2006 02:05 PM

0 Kudos
Message 2 of 10
(8,569 Views)
I made the changes, and it seems to work. I'm going to go test it. Thank you.
0 Kudos
Message 3 of 10
(8,562 Views)
It still doesn't work. I don't know anything about using the run command / command line, so I have no idea how to fix it. All I know is that, with the current program, nothing is called at all. If I change the location of the batch file, nothing happens, even though there should be an error.
 

Message Edited by BobChuck on 12-14-2006 02:31 PM

0 Kudos
Message 4 of 10
(8,562 Views)
Well you do have it set to run minimized. What does the batch file do that you are testing with? If I run a batch file that only has "pause" in it and run minimized is true, I don't ever see a window. It appears as though nothing is happening.
0 Kudos
Message 5 of 10
(8,552 Views)

It doesn't do the same thing. When I run their batch file manually, the window opens and is empty. It does not change for a few seconds, then it closes. When I run the LabVIEW program calling the batch file, a window opens and displays the text "The system cannot find the file specified". It also sits for a few seconds and then closes.

I realize that it is a small difference, but it is a difference, and I have no way of doing an accurate test short of sending the customer another software load.

I don't have a special batch file for testing. All I have is a copy of the customer's batch file, which goes to thier server and retreives the latest set of data that I process.

Message Edited by BobChuck on 12-14-2006 03:07 PM

Message Edited by BobChuck on 12-14-2006 03:18 PM

0 Kudos
Message 6 of 10
(8,552 Views)

Hmm, well try making a test file. Just open notepad, write the word "pause" (without quotes), and save it as test.bat. Try opening this with your VI and see what happens. A window should come up that says "Press any key to continue..."

I'm thinking that the message you are getting in the command window is actually from their batch file. Although I understand that it doesn't show up when you run it manually, which is strange.

0 Kudos
Message 7 of 10
(8,544 Views)
I wrote a small test file as suggested, and things are even strabger. The test file executes the same whether called manually or via LabVIEW, but the customer's batch file is different. I called tech support (go service contract!) and we tried a number of things. The solution, appearently, is to wire the 'location to execute' input. I wasn't doing this because the location to execute is the same directory where the batch file is located.
0 Kudos
Message 8 of 10
(8,533 Views)

Hi,

 

I have been struggling with a similar issue, my .bat file executes correctly when run directly, however seems to run too fast and doesn't execute correctly when called from LabView.

Tried a simple test.bat containing @pause, and still had the same result.

 

Issue:

If I run the test.bat directly, the system pauses and a key stroke is required to close the window.

If called from LabView, the cmd window flashes up and disappears...

 

The same for my other.bat file, which contains code to communicate to a USB device.

When called from LabView, other.bat appears to start, a window flashes up, USB device starts, but the .bat never completes execution...

 

Solution:

Found that if you set "Wait until completion" to FALSE, the .bat file will execute all the commands correctly, and display in the cmd window, as well as wait for user inputs.

If set to TRUE, the SystemExec will run the .bat file to completion (bypasses all user inputs like @pause) and displays all outputs in the "standard output".

 

Tim

Message 9 of 10
(7,578 Views)

Further to the above post, check the file path in the .bat file when calling from LabView...

.bat file would work fine, but need to add absolute path when calling from LabView.

 

 

I had to change this line

 

    "%batch_path%app_name" -b -a 0x2000 -r -f filename.bin

 

to this absolute path;

 

    "%batch_path%app_name" -b -a 0x2000 -r -f "%batch_path%filename.bin"


Cheers

0 Kudos
Message 10 of 10
(7,565 Views)