将参数发送到CMD [英] Send Parameter To CMD
本文介绍了将参数发送到CMD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将参数发送到CMD?例如发送路径并从该路径开始?如何执行CMD命令?
谢谢
How can i send parameters to CMD? for example send a path and start it from that path? How can i execute CMD commands? Thanks
推荐答案
要立即启动 cmd.exe
执行命令,使用 / K
标志:
To start cmd.exe
and immediately execute a command, use the /K
flag:
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellExecute(Handle, nil, 'cmd.exe', '/K cd C:\WINDOWS', nil, SW_SHOWNORMAL);
end;
要在 cmd.exe中运行命令
然后立即关闭控制台窗口,使用 / C
标志:
To run a command in cmd.exe
and then immediately close the console window, use the /C
flag:
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellExecute(Handle, nil, 'cmd.exe', '/C del myfile.txt', nil, SW_SHOWNORMAL);
end;
这篇关于将参数发送到CMD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文