gnolivos Posted January 28 Share Posted January 28 (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 by gnolivos Link to comment Share on other sites More sharing options...
argumentum Posted January 28 Share Posted January 28 (edited) welcome back ? The number is the PID ( https://www.autoitscript.com/autoit3/docs/functions/Run.htm ) use Edited January 28 by argumentum solved Follow the link to see my signature's stuff.FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
gnolivos Posted January 28 Author Share Posted January 28 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? Link to comment Share on other sites More sharing options...
argumentum Posted January 28 Share Posted January 28 ..sure, post the batch file and I'll write the BAT as an AU3 Follow the link to see my signature's stuff.FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
gnolivos Posted January 28 Author Share Posted January 28 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. Link to comment Share on other sites More sharing options...
gnolivos Posted January 28 Author Share Posted January 28 Found an excellent way if doing it here: Link to comment Share on other sites More sharing options...
TimRude Posted January 28 Share Posted January 28 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 Link to comment Share on other sites More sharing options...
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