Jump to content

Run cmd.exe + another exe


Recommended Posts

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:

 

Link to comment
Share on other sites

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 :D
I can use StdoutRead() in a loop or... I don't know... I've never used that function before :D
Thank you again :) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@Subz
Sorry for my "confusion"... :) Read below :D 

@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 :D 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...