Search code examples
delphishellexecute

Multiple 'cmd.exe' commands in one ShellExecuteEx under Delphi


I'm trying to have multiple commands executed in one ShellExecuteEx.

Each command has its own parameters.

How do I do this ?


Solution

  • The simplest way is to write the commands to a temporary file with .bat extension and pass that file name to ShellExecuteEx.

    The alternative involves trying to do it with arguments to cmd.exe. That's going to involve /C, the & or && operators and argument quoting hell.

    My recommendation is to seek an easy life and create a temporary file with your script in.