在 C# Win Forms 中处理这个问题。
如何设置变量并在运行命令复制后?就像现在的代码一样, Process1.startInfo.Arguments = "/k SET etc. etc." 被“/k COPY etc. etc.”覆盖 命令并没有执行。
public void OutputBtn_Process_Click(object sender, EventArgs e)
{
foreach (FileInfo fi in listBox1.Items)
{
Process process1 = new Process();
process1.StartInfo.Arguments ="/k Set filename ="+fi.Name;
process1.StartInfo.UseShellExecute = false;
process1.StartInfo.Arguments = "/k copy /b %filename% test.txt";
//process1.StartInfo.LoadUserProfile = true;
process1.StartInfo.FileName = "cmd.exe";
process1.StartInfo.WorkingDirectory = Path.GetDirectoryName(fi.FullName);
process1.Start();
}
}