cmd.exe如何执行后自动关闭?

How can cmd.exe be automatically closed after execution?

I 运行 cmd.exe 以管理员权限移动文件:

ThisParams := '/K move ' + '"' + ThisSourceFile + '"' + ' ' + '"' + ATargetFile + '"';
Winapi.ShellAPI.ShellExecute(0, 'runas', 'cmd.exe', PChar(ThisParams), '', Winapi.Windows.SW_HIDE);

但是,cmd.exe 进程(虽然不可见)在执行后仍然处于活动状态并在内存中,并在任务管理器中保持可见。

这种情况下cmd.exe如何执行后自动关闭?

As documented /k 使命令解释器在执行传递的命令后继续运行。您应该改用

/c   Carries out the command specified by String and then stops.