4

Background:

Our companies internal user's run our .Net programs on 10-20 windows terminal servers. The executables are all stored on a central file server running windows 2003. Some of the terminal servers are running windows 2003 and some are running 2008.

Issues:

When we release a new version of one of our programs we renamed the files that might be locked (EXE, DLL's, ect.), then we copy the newer version of the file to the proper location. This worked flawlessly until we started introducing windows 2008 terminal servers. Now if a user on one of the 2008 WTS is running the program, then the files are locked in such a way that they cannot even be renamed.

Questions

  • Is there a way to rename the locked file?

  • Is there a way to disable this new feature of 2008 that is locking the EXE files while they are being run?

  • Is there a better solution?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
jColeson
  • 951
  • 1
  • 14
  • 24

3 Answers3

3

Not really. If a file is locked, it's locked and unless the process that holds the lock releases it or the network share connection for that user is disconnected, you can't do much with the file.

You should switch to ClickOnce deployment instead of running the executables from a network share. Aside from the updating issue you describe, running from network share has implications on the code access security, and has a perf impact on the initial load of the application.

zneak
  • 134,922
  • 42
  • 253
  • 328
Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • 1
    Renaming of file is not always an operation with the file contain, but only with the corresponding directory. Only if the file is opened for exclusive access the renaming is not possible. – Oleg Jul 29 '10 at 17:39
  • That is correct. It also appears to be the case in your scenario. :-) – Franci Penov Jul 29 '10 at 17:55
  • 1
    We've tried ClickOnce on our terminal services before and unfortunately ClickOnce isn't very reliable within a terminal services environment. – jColeson Aug 17 '10 at 16:14
3

Our problem turned out to be because of a new feature in windows file sharing called "Opportunistic Locking." It's currently impossible to turn this feature off when both servers are 2008.

We currently have a case open with Microsoft looking for other solutions and work a rounds. Leaning towards using DFS at the moment.

jColeson
  • 951
  • 1
  • 14
  • 24
  • 1
    Microsoft released a [Hotfix](http://support.microsoft.com/kb/2622136) for Windows 7 and Windows 2008 R2 to prevent the locking of used files in shares. I am not sure if this update has been integrated in any Service Pack yet. – Holger Schmeken Jan 27 '15 at 18:26
1

In general you should have no problem to rename locked file on windows 2008 terminal servers exactly as on all previous versions of Windows NT starting with first one Windows NT 3.1.

Probably you have problem with the program which you use for file renaming. You could do this in the old operation systems directly in Explorer, later no more. But it is possible to rename files in CMD.EXE. Just start cmd.exe and try rename command.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • We are using the Exec command in TFS build definition to execute the rename command. My understanding is that the Exec command passes our command directly to cmd.exe. – jColeson Jul 29 '10 at 17:48
  • I don't know which Exec command or Exec.exe program you use. Just start `cmd.exe` and type `rename "\\Server\share\Dir\my.exe" Old.exe`. You can do this over network. – Oleg Jul 29 '10 at 18:30
  • We have a script in our team foundation server that automates our builds. The Exec tasks is part of that. Unfortunately, manually starting cmd.exe and calling rename doesn't work either. I agree with most of the comments here that it *should* work, but it is not. Perhaps I should call Microsoft support. – jColeson Jul 29 '10 at 20:07