Solved

Users currently sharing an executable?

Posted on 2004-03-29
5
122 Views
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.

Thanks,
NC
0
Comment
Question by:NO_CARRIER
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Mikal613
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
0
 
LVL 76

Accepted Solution

by:
David Lee earned 280 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.
0
 
LVL 1

Author Comment

by:NO_CARRIER
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?
0
 
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
    End If
End Sub

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now