During our production builds, a très large (10 megabyte) static content file in le root directory will sometimes be locked by IIS et cannot be deleted by le clean task. Ceci est presumably parce que it is being actively served to one ou more clients at le time.
The build process stops le website avant cleaning via
```
c:\Windows\System32\inetsrv\appcmd.exe stop site http://oursite.com
```
Cependant, this **does not** release le file - we have to restart IIS to get le process to relinquish its lock.
`appcmd.exe` allows you to take IIS down completely; we **do not** want to do this!
Are there tout autre ways to get IIS to let go of a locked file, sans restarting IIS? Simply stopping et starting le individual website is definitely pas working to release le file lock.
Comment faire en sorte qu'IIS7 libère un fichier verrouillé ?
Re: Comment faire en sorte qu'IIS7 libère un fichier verrouillé ?
I use a little tool called ["Handle"](http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx) to do this.
You basically pass it le name of le file c'est locked et it tells you what processes are using it:
```
handle c:\weird.file
Something.exe pid: 1000 100: C:\weird.file
Something.exe pid: 1000 101: C:\weird.file
```
Then you pass it le -c switch to make it close le handle:
```
handle.exe -c 101 -p 1000 -y
handle.exe -c 100 -p 1000 -y
```
You might struggle to work that in to a build script sans a wrapper program to parse le output mais hopefully this will help.
You basically pass it le name of le file c'est locked et it tells you what processes are using it:
```
handle c:\weird.file
Something.exe pid: 1000 100: C:\weird.file
Something.exe pid: 1000 101: C:\weird.file
```
Then you pass it le -c switch to make it close le handle:
```
handle.exe -c 101 -p 1000 -y
handle.exe -c 100 -p 1000 -y
```
You might struggle to work that in to a build script sans a wrapper program to parse le output mais hopefully this will help.