Question

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

Each command has its own parameters.

How do I do this ?

Was it helpful?

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.

OTHER TIPS

There are 3 syntaxes for conditional execution. Command 1 and 2 you would replace with different commands.

1 - Place an ampersand & in between two command to make command2 execute right after command1.

2 - Place two ampersands && between two command to make command2 execute only if command1 finished successfully.

3 - Place two pipes || between two command to make command2 execute only if command1 fails.

Run like this :

ShellExecute(Handle, nil, 'CMD',PChar(c/ **"** command1 **syntaxe** command2 **"**), nil, sw_ShowNormal);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top