|
| ||||||||||
| Tags: close |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| close an open file by name
Windows 2003 Server Standard automatically. In a few google searches, I found people listing a command to close all open files: for /f "skip=4 tokens=1" %a in ('net files') do net files %a /close and one to close individual files: net file ID /close The problem with that is knowing the file ID. To test I tried to open a file on the server, check the ID, close the file and open it again but the ID changed. Does anyone know of a method I could use to close one specific file by name by say a scheduled task or .bat file or anything like that? |
|
#2
| |||
| |||
| Re: close an open file by name "drdraxx" <drdraxx@gmail.com> wrote in message news:1184952859.985132.187460@g12g2000prg.googlegroups.com... > I'm looking for a way to be able to close an open file by name on a > Windows 2003 Server Standard automatically. In a few google searches, > I found people listing a command to close all open files: > > for /f "skip=4 tokens=1" %a in ('net files') do net files %a /close > > and one to close individual files: > > net file ID /close > > The problem with that is knowing the file ID. To test I tried to open > a file on the server, check the ID, close the file and open it again > but the ID changed. Does anyone know of a method I could use to close > one specific file by name by say a scheduled task or .bat file or > anything like that? > You could try oh.exe to obtain the file ID of an open file. Oh.exe comes with the Windows Resource Kit. |
|
#3
| |||
| |||
| Re: close an open file by name "drdraxx" <drdraxx@gmail.com> wrote in message news:1184952859.985132.187460@g12g2000prg.googlegroups.com... > I'm looking for a way to be able to close an open file by name on a > Windows 2003 Server Standard automatically. psfile does this quite well for shared files. http://www.microsoft.com/technet/sys...s/PsTools.mspx |
|
#4
| |||
| |||
| Re: close an open file by name
On Jul 23, 11:55 am, "Brian Spolarich" <bria...@gmail.com> wrote: > "drdraxx" <drdr...@gmail.com> wrote in message > > news:1184952859.985132.187460@g12g2000prg.googlegroups.com... > > > I'm looking for a way to be able to close an open file by name on a > > Windows 2003 Server Standard automatically. > > psfile does this quite well for shared files. > > http://www.microsoft.com/technet/sys...s/PsTools.mspx Thank you for the help. Before I actually saw this response, I figured it out. I had to change up the "for /f "skip=4 tokens=1" %a in ('net files') do net files %a /close " command to take more tokens and do an if statement. Here is what I ended up using in a .bat file: @echo off for /f "skip=4 tokens=1,3*" %%a in ('net files') do if %%b == [path \filename I was looking for] net files %%a /close This basically took the ID and stored it in variable a and took the path and stored it in variable b. The loop then just went line by line through the net files list (starting at line 4 from the skip) and did a compair on the path\filename I was looking for. If it found it, then it would close the file with the ID tag it got from the same line. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "close an open file by name" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Disk util error when tried to open and close an excel file ? | Judah | Windows Software | 3 | 28-11-2010 04:21 AM |
| How to close an open session cd | Anathakrishnan | Windows Software | 3 | 26-06-2009 05:24 PM |
| how to close an open proxy port | Lauren Bacall | Networking & Security | 2 | 24-06-2009 12:16 AM |
| Script to close open files in file server | Gustavo | Windows Server Help | 2 | 22-05-2008 06:59 PM |
| Port 21 (FTP) Open. How to close. | Kenyon | Windows x64 Edition | 2 | 25-01-2008 11:22 PM |