06-04-2020 03:28 AM
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
Solved! Go to Solution.
06-04-2020 06:40 AM
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!
06-04-2020 07:16 AM
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....
06-04-2020 08:05 AM
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.
06-04-2020 12:04 PM
@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.
06-05-2020 02:04 AM
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...
06-05-2020 02:44 AM
@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.