简体   繁体   English

如何在Delphi中不运行cmd的情况下运行命令

[英]How to run a command without running cmd in Delphi

I want to run a command from Delphi. 我想从Delphi运行命令。 I can do it using ShellExecute . 我可以使用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 . 但是我不想使用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);

It is possible to perform some of your tasks without invoking cmd but not all. 可以执行某些任务而无需调用cmd,但不是全部。 For instance del is a built in command of the cmd interpreter and therefore needs to be interpreted by cmd. 例如, del是cmd解释器的内置命令,因此需要由cmd解释。

Of course, you don't need to get cmd to execute del in order to delete a file. 当然,您不需要获取cmd即可执行del来删除文件。 That is trivially easy using the API provided by the operating system. 使用操作系统提供的API,这很容易。 So it's quite possible that you can avoid cmd if you wish. 因此,如果您愿意,很可能可以避免使用cmd。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM