helyonprime96
asked on
delphi : how to execute a cmd command?
hello huys.
please help.
how i can execute a cmd command from delphi app? (look like rasdial)
it maybe something like this :
exec ('rasdial life);
Thanks.
please help.
how i can execute a cmd command from delphi app? (look like rasdial)
it maybe something like this :
exec ('rasdial life);
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok.thanks.i will test
That may help you also,
https://www.experts-exchange.com/questions/27044422/how-would-delphi-open-cmd.html
good luck
https://www.experts-exchange.com/questions/27044422/how-would-delphi-open-cmd.html
good luck
ASKER
thanks
A very simple way is to simply call ShellExecute with passing the DOS command in as a parameter. E.g. to create a copy of c:\1.txt as c:\2.txt we can use the following:
ShellExecute(
Application.Handle, 'open', 'cmd.exe',
'/c copy c:\1.txt c:\2.txt', // this way we told cmd.exe to execute copy ...
nil, SW_SHOWNORMAL);
Should you need to wait for the outcome (exit code), a better solution would be using the CreateProcess API.
But in case you need the output (stdout) things can get complicated. Do you?