Results 1 to 4 of 4

Thread: close an open file by name

  1. #1
    drdraxx Guest

    close an open file by name

    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?


  2. #2
    Pegasus \(MVP\) Guest

    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. #3
    Brian Spolarich Guest

    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. #4
    drdraxx Guest

    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.



Similar Threads

  1. Replies: 3
    Last Post: 28-11-2010, 05:21 AM
  2. Script to close open files
    By ara in forum Windows Server Help
    Replies: 2
    Last Post: 31-08-2010, 05:49 PM
  3. How to close an open session cd
    By Anathakrishnan in forum Windows Software
    Replies: 3
    Last Post: 26-06-2009, 05:24 PM
  4. Script to close open files in file server
    By Gustavo in forum Windows Server Help
    Replies: 2
    Last Post: 22-05-2008, 06:59 PM
  5. Port 21 (FTP) Open. How to close.
    By Kenyon in forum Windows x64 Edition
    Replies: 2
    Last Post: 26-01-2008, 12:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,646,182.02946 seconds with 17 queries