1

I want to run a command from Delphi. I can do it using ShellExecute.

This is how I do it:

 ShellExecute(0, nil, 'cmd.exe', '/c start http://localhost/ ', nil, SW_HIDE);

But I want do this without using cmd. Is there any way to do it?

I want to run below command as well:

ShellExecute(0, nil, 'cmd.exe', '/c del RUNNING_PID', nil, SW_HIDE);
ShellExecute(0, nil, 'cmd.exe', '/c .\bin\posonline-phm -Dhttp.port=80 -Dconfig.file=.\conf\application.conf ', nil, SW_HIDE);
7
  • What about using the Stack Overflow search box? delphi+start+browser+with+url Commented Mar 3, 2017 at 2:22
  • It didn't help me. I want run a command without using cmd. I gave only a one example. I have some other commands also. Anyway i will edit the question. Commented Mar 3, 2017 at 2:31
  • If you wish to pass localhost to the shell with an appropriate verb, that is possible. Is this the only form of command? Commented Mar 3, 2017 at 2:33
  • @DavidHeffernan No. There are some other commands. I have edited the question. Commented Mar 3, 2017 at 2:35
  • 1
    "del" is a command, and cmd is the command interpreter. No can do. Commented Mar 3, 2017 at 2:36

1 Answer 1

1

It is possible to perform some of your tasks without invoking cmd but not all. For instance del is a built in command of the cmd interpreter and therefore needs to be interpreted by cmd.

Of course, you don't need to get cmd to execute del in order to delete a file. That is trivially easy using the API provided by the operating system. So it's quite possible that you can avoid cmd if you wish.

Sign up to request clarification or add additional context in comments.

2 Comments

Okay. i will do delete without using cmd. Is there way to do others without cmd?
For the first one pass the URL to ShellExecute or ShellExecuteEx. The other one appears to be starting a new process. That's CreateProcess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.