I am currently writing a command line application in AutoIt and am having trouble with making it print back to the same command line I opened it in. My goal is to have the entire program work within a single shell. Here is what I tried initially:
;myprogram.au3
$MyCommand = 'dir'
Run(@ComSpec & " /c " & $MyCommand, @SystemDir, @SW_Show)
Run(@ComSpec & " /c @echo off && echo Command completed successfully. && @echo on", @SystemDir, @SW_Show)
Then I compiled it and ran it via the command line (each code box represents a new shell):
C:\Users\Matthew>myprogram.au3
C:\Users\Matthew>
Opens new shell ↓
Volume in drive C has no label.
Volume Serial Number is 0287-990C
Directory of C:\Users\Matthew
<Finishes normal dir command output>
Once finished, listing files in my directory that exits and
Opens new shell ↓
The command completed successfully.
And that window closes immediately.
The output I am looking for is the same thing, but in one window, like this:
C:\Users\Matthew>myprogram
*Output of dir command*
The command completed successfully
C:\Users\Matthew>