Mandy said:
I want the server not to shutdown if in case an app of mine is still open in another computer..
If I understand this correctly, you want the server to stay available whenever it is still needed. Well, I think my puzzling comes from a standarad you don't seem to know or use: A server, also just a file server, is something that usually runs uninterrupted and is never shut down except for maintenance.
Mandy said:
I want to tell the server user not to shutdown that computer server if sessions are still open in other computer.
Well, from what I just said you simply have to tell the user that works on a server (which is unusal), that it's the server and is not a workstation like others, it's not shut down at all.
That might not be the case for you, perhaps as reason for saving energy, but if the server should be available when a user starts the application, well, you can't even shut it down when you're sure no user is currently needing the database and tables files at all, because that can change at any moment.
In short: It's very usual the server runs 24/7 and no user works at it. But if you need this, then one simple to implement solution is schedule the shutdown of the server to after work hours. If it's a good server hardware it might also allow wake-on-LAN and be started by schedule again in the morning before any user works.
You also say yourself clients may just have crashed or are idle not using tables, then you still don't want to shutdown, so the only real sure state is by time schedule, isn't it?
So, okay, lets limit it to one case: A user wants to know whether currently no files are used before shutting down the server, then there's this tool about finding out who has open file handles on a server:
Please read the details in this blog article, it has important requirements about permissions of the user doing that code besides other restrictions, it's important you understand them.
Trying to get all exclusive access to all database files is more specific to your application, but this will also in general list user having open server files, which could also be office documents or others. And when this server isn't just acting as a file server but as primary domain controller, the server into which users log in, you surely have more to the point solutions from server administration side than you have looking into just the database files. But then also even less reasons to shut such a server down.
Chriss