Go Premium for a chance to win a PS4. Enter to Win


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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

971 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