A daily windows scheduled task triggers a batch script which moves program files to a folder on a server, using a simple copy routine.
rem deploy programfiles
copy dailybuild\*.dll "\\myserver\programfiles" /Y
copy dailybuild\*.exe "\\myserver\programfiles" /Y
This works just fine, unless someone is actually running the executable file, which is causing the copy to fail due to a locked file.
As this is on a terminal server, and a user may run the exe file from a shared folder (not creating a process on the terminal server), I can't find the right approach do solve this issue.
How may I release any locked files before the copy is executed? The crude solution may be to restart the terminalserver, but I hope there's another solution at hand.
Currently I am using regular batch script, and I haven't looked into powershell yet.
Anyone with a 'best practice' solution for this issue?