【问题标题】:Running a program after copy file, in one Windows CMD line?复制文件后在一个 Windows CMD 行中运行程序?
【发布时间】:2015-12-26 16:59:37
【问题描述】:

我尝试创建 Visual Studio 构建后事件命令行并且我想要:

  1. 如果存在则终止进程;
  2. 复制文件;
  3. 启动程序;

start taskkill /f /im app.exe /t & xcopy /y "$(TargetPath)" "C:\Program Files (x86)\path\$(TargetFilename)" & start "" "C:\Program Files (x86)\program\app.exe"

我使用start taskkill /f /im app.exe /t而不是taskkill /f /im app.exe /t,因为如果进程不存在我会得到not found错误

现在所有树命令运行正常,没有错误,但最后一个命令没有启动程序,但如果我单独执行这个命令,程序就会被执行。

我该如何解决这个问题?

【问题讨论】:

标签: windows visual-studio command-line cmd post-build-event


【解决方案1】:

你有一个时间问题。

试试:

start /wait taskkill /f /im app.exe /t & xcopy /y "D:\Workspaces\Dev\path\bin\Debug\my.dll" "C:\Program Files (x86)\path\my.dll" & start "" "C:\Program Files (x86)\program\app.exe"

【讨论】:

  • 是的。这就是问题所在。这个wait 解决了我的问题。谢谢斯蒂芬。
猜你喜欢
  • 2019-08-08
  • 2013-09-04
  • 1970-01-01
  • 2020-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-24
  • 2011-12-24
相关资源
最近更新 更多