LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to run a batch file (sounds easy...)?

Hallo,

I just tried a lot of things to run through a simple button a prepared Batch-File. I used the execute-command but it does not work proper. There is an error message.
Hope it is easy to solve. How can I execute / run / start an batch file, because just to execute it through the execute-command does not work?

Thx for help

Bauch@bessy.de
0 Kudos
Message 1 of 10
(8,010 Views)
I am not aware of an execute command in LabVIEW. do you mean System exec.vi?

Could you clarify what kind of batch file this is? (e.g. DOS *.bat file?).
What is the error message?
Can you show an image of your code?
0 Kudos
Message 2 of 10
(8,001 Views)
I cannot post the error because I do not have the program right here but I used the Execute-Command which you can find under the "program control"-vis (or similar). I try to use a simple DOS-Batch file.

Maybe I have to post the error later.

Best thx for help
0 Kudos
Message 3 of 10
(7,980 Views)
Now I can tell u a little bit more. I use the system exec.vi where I directly use the >>commandline-input<< to run the batch e.g.: c:\test.bat. I already use the commandline to run a textfile like this "Notepad c:\test.txt" and that works but to run a Dos-Batch-file it is obviously that labview
needs special command what to do with that file. I already tried to use "CMD c:\test.bat" or "run ..." or "exec... " but this does not work.
Hope someone can help.
0 Kudos
Message 4 of 10
(7,963 Views)
Hey!

Try this VI (LV 6.0 and 7.1 versions included). I use it pretty much for everything. Will launch .bat and .exe, will also open most files types, like .pdf, .doc, .jpg, etc., in their respective default applications.

Good luck!

Zador
Message 5 of 10
(7,957 Views)
Hi,

Set the "working directory" parameter of System exec.vi to the directory where the batch file is located.
Peter Griese
NI
0 Kudos
Message 6 of 10
(7,933 Views)
From the previous posts, I've been able to start/call an external application from LabVIEW.  Is there a way to embed that external application so that it is part of your LabVIEW window?
 
For instance, I want my LabVIEW application to not only start up a Windows command window, but to have that command window built into a fixed location on my LabVIEW app.  Functionally, it will work just fine to have the the cmd window free floating as a separate entity, but a more seamless and integrated approach would be to have a "picture in picture" type functionality.
 
I have not experimented with subpanels that much, but can anyone comment if that is a step in the right direction?
 
0 Kudos
Message 7 of 10
(7,320 Views)

Hi, Zador,

I saw your this email today, and tried it. It works fine for me. The only question is that what if I have a parameter in the bat file. For example, I want to run test.bat 2, rather than test.bat. I tried to put C:\test.bat 0 in the path, but it was not recognized and gave me an error message.

Thank you. Not sure if you still monitor the questions......

Regards,

Xuedong

0 Kudos
Message 8 of 10
(7,214 Views)

Try to concatenate your option string after the "path to string" function.

0 Kudos
Message 9 of 10
(7,203 Views)
Thank you very much! It works now.
0 Kudos
Message 10 of 10
(7,184 Views)