ShellExecute(0,'open','cmd.exe','/k ipconfig /flushdns', pchar(sysdir+'\system32\'),SW_HIDE); 

How then to close cmd.exe correctly? in the processes it remains to hang after execution.

    1 answer 1

    This function (ShellExecute) returns a number more than 32, if the execution is successful, otherwise - the error code. Msdn You can search for the application you have opened using the enumerator of processes. But it seems I know what you need to do. You are trying to execute the console command in the background, but you can’t do it discreetly. In this case, simply open cmd.exe с параметром /с - in this case, the console will immediately close itself after the command is executed.

    • Ok, works. Thank you - Malus
    • Please =) - Salivan