From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create an EXE able to read and write the console

Hello the forum,

i'm trying to code a VI that will be built as an EXE and called by another VI using the System Exec function.

 

The EXE should be able to:

1. read an input string from the console that will be treated as soon as the called EXE starts running

2. write an output string to the console that will be treated as soon as the called EXE ends running

 

Here's the result of my search (in terms of links):

https://forums.ni.com/t5/LabVIEW/how-to-make-a-VI-write-to-standard-output/td-p/347392

https://forums.ni.com/t5/LabVIEW/console-app-from-labview-VI/m-p/77569

https://forums.ni.com/t5/LabVIEW/Standard-output-on-system-exec-VI/td-p/3358128

http://dslweb.nwnexus.com/~ast/dload/guicon.htm

https://docs.microsoft.com/en-us/windows/console/getstdhandle

https://docs.microsoft.com/en-us/windows/console/writeconsole

https://forums.ni.com/t5/Developer-Center-Resources/Passing-and-Receiving-Pointers-with-C-C-DLLs-fro...

https://forums.ni.com/t5/LabVIEW/Calling-subroutines-from-dll/td-p/151367

 

And attached there's a screenshot of what i coded on the diagram of the called EXE. A file is generated with the errors details and the values coming from the Kernel32 funcitons. An error code 1097 appears as the first function is called.

 

Any clues on how to achieve the goal?

Thanks!

 

 

0 Kudos
Message 1 of 12
(4,231 Views)

@aRCo

i'm trying to code a VI that will be built as an EXE and called by another VI using the System Exec function.

 

 


I think more information is needed here. A simple explanation of what you are trying to do besides:

 

The EXE should be able to:

1. read an input string from the console that will be treated as soon as the called EXE starts running

2. write an output string to the console that will be treated as soon as the called EXE ends running

 

 

What does "treated as soon as the EXE starts" and "treated as soon as the EXE ends running" mean?

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 12
(4,203 Views)

I overloaded the previous message with unuseful info. The two points can be modified as follows:

 

The EXE called by the System Exec function should be able to:

1. read an input string (containing parameters) from the console

2. write an output string (containing results) to the console

0 Kudos
Message 3 of 12
(4,182 Views)

Hi arco,

 

1. Enable command line parameters when building the EXE. Read the command line parameters using an App property node…

2. You already linked to threads discussing this issue. (LabVIEW is a GUI tool, which don't support console output…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(4,179 Views)

@GerdW
LabVIEW is a GUI tool, which don't support console output…

Really? I thought LabVIEW could do everything... 😉 ...and it seemed to me that someone implemented something similar.

 

Am i really forced to use (for example) a temprary file to exchange data to and from the called EXE?

0 Kudos
Message 5 of 12
(4,162 Views)

@aRCo wrote:

@GerdW
LabVIEW is a GUI tool, which don't support console output…

Really? I thought LabVIEW could do everything... 😉 ...and it seemed to me that someone implemented something similar.


There is a big difference between what LabVIEW can do, and what LabVIEW can do practically.

 

There is also a difference between what can be done in LabVIEW, and what anyone can do in LabVIEW.

 

Even if it has been done, I doubt it turned out to be an elegant solution.

 

Big question is why would want to do this? An exe seems like the least convenient solution. Make a .dll, it's designed to be used like this. A .dll is an exe in almost every aspect. It just adds loading\unloading functions (that are irrelevant in this context), and extra entry points (although an exe can have those as well).

0 Kudos
Message 6 of 12
(4,155 Views)

wiebe@CARYA wrote:

@aRCo

Big question is why would want to do this?


My question exactly...

 

Tell us what exactly you are trying to accomplish here and maybe we can come up with a better way.

 

BTW: LabVIEW can NOT do "everything". LabVIEW is a tool and while it is often the right tool for the job, sometimes it is not.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 12
(4,148 Views)

Hi all,

finally I implemented two ways:

 

1. The EXE way, that, instead of read/write the console, it uses files to accomplish the same goal

2. The VI way, setting/getting directly the values of the input/output terminals of the connector pane of the called VI (builded inside a LVLIBP)

 

Which other solutions could I have implemented?

0 Kudos
Message 8 of 12
(4,092 Views)

@aRCo wrote:

Which other solutions could I have implemented?


 A dll.

0 Kudos
Message 9 of 12
(4,083 Views)

wiebe@CARYA a écrit :

@aRCo wrote:

Which other solutions could I have implemented?


 A dll.


Yes, thanks! I'll try to find the time to implement this other solution 😉 Have a nice day

0 Kudos
Message 10 of 12
(4,077 Views)