0

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?

Kman
  • 101
  • 2

1 Answers1

1

You could use a 3rd party tool to help you do this. There is a tool call "HoboCopy" that utilizes Volume Shadow Copy to make a copy of an in use file.

Here is a cool howtogeek article on how to use it.

user69486
  • 31
  • 3