Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Users currently sharing an executable?

Posted on 2004-03-29
Medium Priority
Last Modified: 2010-05-02
My application is on a shared network drive.  Anyone in the department can open / access it.

However, sometimes in the evenings when I want to put a new build on the network there is a sharing violation.  Some users lock their computer with the application open.

I'd like to be able to track which users are currently using the application.  Perhaps a text file of some type with a time-stamp, and is updated every 5 minutes or so... (timer), if it's not updated it times out and removes the user from the list?

Is there another method to do this?  I'd just like to track which users have it open.. so if necessary I can unlock / reboot their systems.

Question by:NO_CARRIER
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 48

Expert Comment

ID: 10709616
If there is a database attached to it you can have your program looking for a field (every minute) yes/no if yes then shutdown  and when you wanna update then just update that field
LVL 76

Accepted Solution

David Lee earned 840 total points
ID: 10710365
How about using a timer control in the application itself so that after a certain amount of inactivity the program shuts itself down?  That sounds like a safer approach to me than trying to maintain a list of who has the program open.  The problem I see with the list approach is that there are probably situations that could arise where the text file was not updated yet the program was still running on someone's PC.  An inactivity timer would cause the program to shut itself down without any intervention.  Another approach would be to add a routine that'd allow you to shut the application down remotely.  For example, you could have the program check periodically for a certain file or for a value in a file or database.  On finding that file or value all instances of the application would close themselves out.  For example, you could create a file called Configuration.Ini.  Write a routine that checks that file periodically and reads a value called ForceShutdown.  If ForceShutdown is set to True, then the application shuts itself down.  Otherwise it goes about its business.  You could expand on that concept some to control access to the program as certain times.  Say you need to apply a patch during the business day, when staff are most likely to be using the app.  Instead of ForceShutdown lets say the value is called OperatingMode.  When OperatingMode is set to Production, then the app runs like normal.  But, when you set OperatingMode to Administrative, then not only do active instances of the program shut down, but anyone who tries to start the app will receive a polite little pop-up telling them the app is currently unavailable.  In addition to the routine that check for the OperatingMode periodically, you'd also need to write a little code that'd check the value as the app starts up.  Both would be very simple to do.

Author Comment

ID: 10725554
yes, the exe is currently hooked up to a database... (does not connect at runtime though.)
Forcing to shut down is an option, but it could become annoying to some of the rep's here.

Would there be a problem of simply adding their lanID to a text file when the open the application, and remove their name on unload?
LVL 76

Expert Comment

by:David Lee
ID: 10728206
Adding the LAN ID to a text file when the app starts and removing it when it unloads presumes that the app will always shut down gracefuly.  What happens when it doesn't?  There are any number of situations that could bypass a graceful shut down.  Things like a the PC losing power, an OS crash, an employee terminating the app via task manager, etc.  Any time the app didn't go through a normal shut down, then that LAN ID would still be there in the text file leaving you to believe that the app was still running on some PC.  How would you handle startup if for some reason the app couldn't write to the file holding the LAN IDs?  That's probably less of an issue than the app not shutting down properly, but it is still a possibility.

I'd think the second option I discussed would be the best.  Add a timer control and check for a given file or an entry in a file periodically (i.e. some triggering option).  If the app sees the trigger, then it pops a nice notice up on screen telling the user that it's going to shut down in a certain amount of time, then goes through an orderly shutdown.  The code for this is very simple.  Here's an example:

Dim objFSO as FileSystemObject

Private Sub Timer1_Timer()
    If objFSO.FileExists("C:\KillApp.Txt") Then
        'Shutdown code goes here.
    End If
End Sub

Private Sub Form_Load()
    Set objFSO = New FileSystemObject
    Timer1.Interval = 60000    'Check for the file once a minute
End Sub

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question