WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to determine if a file is/is not in use on LAN

Keywords: 	 network file in use

Question:

I've written a login script using Winbatch. I need to update it occasionally. I'm having trouble replacing it, because it's being used & the LAN (NT 4) won't let me overwrite it while it's in use. OK, I understand that. I end up waiting until REAL late to copy the file out to the LAN. Problem is that I'm finding that folks are staying later & later.

What I'm looking for is a way to determine IF the file is in use & When it's NOT in use copy the new one over it. That way I can start a winbatch prog & go home & it'll copy the file out, log the time (so I'll know it got done) & then log the PC off & shut down.

I can do ALL that EXCEPT tell if the file is in use.

I've tried "AppExist" , "FileSize", "wntFileClose", & looked around on the Web board & tech support & tried everything I found with no luck.

Answer:

  1. When we ran into this problem, we ended up using two programs. The first program looks at an INI to tell it where the second program is. Then it calls the second program. To update the program, use a new name and update the INI, which is much easier. Remove the old one next week, if you ever remember to.

    This first program can be generic and used by all network programs as well!

    Hopefully you don't need to update the first program very often...

  2. You also could use wntFileUsers to see which users are accessing the file.
    ;* Determine if this is Windows 95 or Windows NT
    
    If WinMetrics(-4) == 4
    Windows = "NT"
    Endif
    If WinMetrics(-4) == 5
    Windows = "95"
    Endif
    
    If Windows == "NT"
    AddExtender ("WWWWNT34I.dll")
    Else
    Message("Error","You must be on an NT workstation to execute this command")
    exit
    Endif
    
    Filetocheck="q:\q drive\mis\database\global.mdb"
    GoSub CheckFile
    
    exit
    
    :CheckFile
    
    users=wntFileUsers( "\\MSO",filetocheck)
    
    totusers = ItemCount(users, @TAB)
    
    cnt = 0
    while cnt < totusers
    cnt = cnt + 1
    if cnt <= totusers
    ; ...do something with the information
    newline=ItemExtract(cnt,users,@tab)
    display(1,"user accessing file",newline)
    Endif
    EndWhile
    
    return 
    

Article ID:   W14265
Filename:   How to determine if a file is in use on LAN.txt
File Created: 2001:03:01:14:16:30
Last Updated: 2001:03:01:14:16:30