gnolivos Posted January 28, 2023 Posted January 28, 2023 (edited) Hello, I am back with Autoit after 15 years... I have forgotten many basics it seems, but this one I am ashamed of asking! I can't figure it out... I am running a BAT file from within AutoIt. The BAT file with output some simple text when I run it in the windows shell console, for example: C:\Program Files\tos428cl>tos428cl.bat getport COM6 The resulting text is "COM6". How can I use @ComSpec to obtain the resulting text (COM6) and capture it in a variable? I tried: $comportRequested = Run(@ComSpec & ' /c ' & """" & $PathTOS428cl & "tos428cs.bat"" getport""", $PathTOS428cl, @SW_HIDE) however when I read value from $comportRequested it gives me back a different number each time, like 1162, 1728, etc.. Thanks! Edited January 28, 2023 by gnolivos
argumentum Posted January 28, 2023 Posted January 28, 2023 (edited) welcome back ? The number is the PID ( https://www.autoitscript.com/autoit3/docs/functions/Run.htm ) use Edited January 28, 2023 by argumentum solved Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
gnolivos Posted January 28, 2023 Author Posted January 28, 2023 Thanks. Still not sure about adding snippet code includes... my main code is 30 lines, so Im looking to just add a few lines and learn how to do it. I realize now I am looking at the PID number thanks Can you help me rewrite that code of mine to capture the output of the BAT file instead?
argumentum Posted January 28, 2023 Posted January 28, 2023 ..sure, post the batch file and I'll write the BAT as an AU3 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
gnolivos Posted January 28, 2023 Author Posted January 28, 2023 I said BAT to be generic... its actualy an EXE that runs in command line mode. I would really like to simply catch the output ins a few lines, but if that's not realistic I will find another way. not trying to error handle much etc.
gnolivos Posted January 28, 2023 Author Posted January 28, 2023 Found an excellent way if doing it here:
TimRude Posted January 28, 2023 Posted January 28, 2023 Have a look at the StdoutRead function and the example in the help topic about it. https://www.autoitscript.com/autoit3/docs/functions/StdoutRead.htm
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now