运行cmd脚本而不将其作为批处理文件从Delphi 2010应用程序中写入磁盘

时间:2022-03-20 04:52:10

Is there a way to run a complex command script (batch file) without writing it to disk?

有没有办法运行复杂的命令脚本(批处理文件)而不将其写入磁盘?

I would like to type my script inside a memo and then ShellExecute it on button press without writing it to disk first.

我想在备忘录中输入我的脚本,然后按下按钮按下ShellExecute它,而不先将其写入磁盘。

1 个解决方案

#1


Here is the solution that I tested and it works. Thanks for the answers!

这是我测试的解决方案,它的工作原理。谢谢你的回答!

var: script_lines:string;

script_lines:='hostname & getmac & ipconfig /all & tasklist';

ShellExecute(Handle, 'open', PChar('cmd.exe'), PChar('/k '+script_lines), nil, SW_SHOW);

#1


Here is the solution that I tested and it works. Thanks for the answers!

这是我测试的解决方案,它的工作原理。谢谢你的回答!

var: script_lines:string;

script_lines:='hostname & getmac & ipconfig /all & tasklist';

ShellExecute(Handle, 'open', PChar('cmd.exe'), PChar('/k '+script_lines), nil, SW_SHOW);