FrancescoDiMuro Posted April 7, 2017 Posted April 7, 2017 Good morning AutoIt community! Today, I'm here to ask you if you know how to run an .exe from cmd.exe ( Command Prompt )... My intention is to read a .ini file where I store an information that has to be included in the shell, and run an .exe with that information... I'll give you an example Local $aFileCartellaAuditCopy = _FileListToArray($sPercorsoAuditCopy, "*.txt") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura della lista dei file nella directory" & @CRLF & $sPercorsoAuditCopy & @CRLF & "Errore: " & @error) Return False Else Local $iPID = Run("cmd.exe" & ' /k "C:\Users\Portatile-60\Desktop\HmiCheckLogIntegrity.exe" "C:\Users\Portatile-60\Desktop\AuditTrailDosaggio0_20170327_151335_DOSAGGIO_PW_01.txt"') ; & " /k " & '"' & $sHmiCheckLogIntegrity & '"' & " " & '"' & $sPercorsoAuditCopy & "\" & $aFileCartellaAuditCopy[1] & '"', "", @SW_SHOW, $STDOUT_CHILD) Return True EndIf This code is in a function, that returns False if it can retrive at least a file from the path stored in the .ini file... Else I would like to run the Command Prompt with the .exe and with a parameter of that .exe, but it seems to not work properly. Could please anyone tell me why? Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Subz Posted April 7, 2017 Posted April 7, 2017 Any reason you don't use either IniRead or IniReadSection? Does the application require elevation, i.e. #RequireAdmin to run? Does it need to be run in 32/64?
FrancescoDiMuro Posted April 7, 2017 Author Posted April 7, 2017 Hey @Subz, thanks for your quick reply I did manage to run the .exe, and now I have to read the STDOut from the shell... ( By the way, I use IniReadSection(), but I didn't post that code ( because it's in another function, sorry ) I can use StdoutRead() in a loop or... I don't know... I've never used that function before Thank you again Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Subz Posted April 7, 2017 Posted April 7, 2017 So confused to what your question is? Here is a basic StdOutRead procedure, not sure if that's what you were after? Local $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop WEnd MsgBox(48, "Stdout Read:", $sOutput)
Developers Jos Posted April 7, 2017 Developers Posted April 7, 2017 Show the code that isn't working and pulling the info from the INI. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
FrancescoDiMuro Posted April 7, 2017 Author Posted April 7, 2017 (edited) @Subz Sorry for my "confusion"... Read below @Jos Happy to see you here I've managed to run the .exe as I said in the previous post, and know I have to read the content of the STDOut, in order to compare the result from the ".exe" I've launched, and do what I need to do I tried in this way, but it returns blank "result": Local $sSTDOutRead = "" While 1 $sSTDOutRead = StdoutRead($iPID) If @error Then ExitLoop WEnd MsgBox($MB_ICONINFORMATION, "", $sSTDOutRead) ; This returns blank MsgBox! Thanks for you help guys EDIT: I've managed to correct the $sSTDOutRead with the "&" before the =...@TheDcoder I'll try it asap! Thanks Edited April 7, 2017 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TheDcoder Posted April 7, 2017 Posted April 7, 2017 You can try my Process UDF which is capable of returning the STD output for you EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
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