LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to launch interactive cmd application

Solved!
Go to solution

hi all, I want to start external .exe app which has a command line interface only and requires some basic interaction with it like pressing y and enter

The Idea is that user has to see the cmd windows and do something there

 

for example when I try to do it using System Exec with command line

cmd /k dir

I see no output in the window which pops-out when I mouse click on it the window title changes form Administrator to Select administrator

 

0 Kudos
Message 1 of 7
(6,969 Views)

Hello!

If I understood what You are trying to do, You could try calling "cmd.exe /c start cmd.exe". This opens a new prompt on the screen. If you set the System Exec vi to wait for completion, it will wait until the prompt is closed. Relevant documentation can be found here: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/start

 

Hope this helps!

0 Kudos
Message 2 of 7
(6,927 Views)

thanks for idea, but it's not perfect: when the program finishes to execute the shell window remains opened

for example:

cmd.exe /c start dir /?

the perfect solution would be for me if then you pres any key the window will close itself so the user is not confused

I want to use it to show progress of flashing uC by external executable shipped by uC manufacturer, unfortunately the user has to press space during flashing to confirm memory erase....

0 Kudos
Message 3 of 7
(6,918 Views)
Solution
Accepted by topic author tcie

You could do this programatically from within LabVIEW, There are a couple of tools out there. This is one that I use

 

https://lavag.org/topic/21111-interactive-command-line-using-net/

 

Another one is called LV-Process which I can't find at the moment, it is on GitHub somewhere.

Message 4 of 7
(6,909 Views)
Solution
Accepted by topic author tcie

@tcie wrote:

thanks for idea, but it's not perfect: when the program finishes to execute the shell window remains opened

for example:

cmd.exe /c start dir /?

the perfect solution would be for me if then you pres any key the window will close itself so the user is not confused

I want to use it to show progress of flashing uC by external executable shipped by uC manufacturer, unfortunately the user has to press space during flashing to confirm memory erase....


If You want the command window to close automatically after the executable is done, you could try running the executable directly using

 

cmd.exe /c start name_of_executable.exe

 

Or You could try starting the command in the new console by calling the executable there:

 

cmd.exe /c start cmd.exe /c name_of_executable.exe

 

I don't have a CLI-executable at the hand to properly test it, but this example seems to work just like You wanted:

 

cmd.exe /c start cmd.exe /c "dir & choice"

 

The "choice" command waits for user input and then closes (see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/choice). If you omit it, "dir" will immediately quit.

0 Kudos
Message 5 of 7
(6,874 Views)

cmd /c start cmd /c dir /?
good when simple user interaction in command line is needed, but you won't get any standard output from it...

0 Kudos
Message 6 of 7
(6,846 Views)

@tcie wrote:

cmd /c start cmd /c dir /?
good when simple user interaction in command line is needed, but you won't get any standard output from it...


Then the tool described by @Niatross seems to be the way to go. For a quick solution, You could also have the nested command write it's output to a file and than read that file. Without checking, I would guess that there is even a .NET solution where You just insert the shell as a whole.

0 Kudos
Message 7 of 7
(6,839 Views)