TotPeRo
TotPeRo

Reputation: 6791

Running a program after copy file, in one Windows CMD line?

I try to create visual studio post-build event command line and i want:

  1. to kill process if exist;
  2. copy file;
  3. launch a program;

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

I use start taskkill /f /im app.exe /tinstead of taskkill /f /im app.exe /t because if the process not exists i get not found error

Now all tree command runs OK with no error but the last command not launch the program but if i execute this command separately the program is executed.

How can i fix this?

Upvotes: 0

Views: 1047

Answers (1)

Stephan
Stephan

Reputation: 56218

You have a Timing Problem.

Try:

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"

Upvotes: 1

Related Questions