01-25-2024 08:17 PM
Hello All:
I am running LV 2023 32-bit and I am having trouble closing the command window in LabVIEW using the System Exec VI.
Please see the attached pic for my settings.
When I double click the .bat file, after the file completes the window disappears. I opened up the .bat file with Notepad+ and there is an exit command at the end of the program. When I run it in LV, the window remains open and I have to type "exit" in the command window.
I found this knowledgebase article:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7lUSAS&l=en-US
In the article, solution number 2 states " use the command .com program with the /C flag". I've tried different combinations to no avail. Can somebody help me with this?
Thank you
01-26-2024 01:48 AM
If you would lake to have command prompt closed when called program completed, may be more simple solution will be suitable for you:
01-26-2024 01:31 PM - edited 01-26-2024 01:35 PM
Typing the following at the prompt will close the Command Window:
Make a .Bat file using the Start for your LabVIEW program followed on the last line with the Exit command.
01-26-2024 03:47 PM
Here is the .bat file with all the exit commands in red. As stated, when I double click on this .bat file everything works great, the command window closes. It's when I use the System Exec VI, I need to type "exit" into the command window to get it to close. (I have wait until close set to TRUE)
01-26-2024 06:43 PM
Hello All:
I found a thread where somebody else had the same issue.
https://forums.ni.com/t5/LabVIEW/CMD-EXE-Output-Not-Showing-up/m-p/729103
Here is an excerpt from the author
"Long story short, the only feasible way I found to achieve the desired behavior is this:
Run System exec.vi with "cmd /c start batchfile.bat"
This allows you to view the batchfile's output (live) while also waiting for its completion in the labview code. The only drawback I see is that the terminal does not exit automatically when the batchfile finishes. To circumvent this issue just put an "exit" command at the end of your batchfile."
However, I DO have an exit at the end of my .bat file and the command window is still there 🤔
01-27-2024 12:33 AM
@geekodude wrote:
Run System exec.vi with "cmd /c start batchfile.bat"
This allows you to view the batchfile's output (live)...
I DO have an exit at the end of my .bat file and the command window is still there 🤔
Ah, OK, you would like to see live output. Then its corect, but you have to put exit at the end of called batch file, then it works, at least for me: