enforce single instance of the app over a network

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wild123
    New Member
    • Aug 2012
    • 6

    enforce single instance of the app over a network

    Hi,
    I have an application that runs off a file server and can be accessed over the LAN network by 10+ machines.

    I want to ensure that only one instance of the application run at any time over the entire network.

    the "Previnstan ce" method does not work as it checks only on the local machine and not the network.

    Also cannot create a check file which is deleted at close as the application has a tendency to crash at times.....
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use WMI to check the other machines to see which processes are running. Exit the program if it's already running on another machine. The users will need remote access to each other's computers and may need admin access to use WMI.

    As a side note, you should probably fix the issue causing the crashes rather than working around it.

    Comment

    • wild123
      New Member
      • Aug 2012
      • 6

      #3
      all machines do not have access to other machines......

      can the previnstance method not be used at the server level????

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        For that to work, I'd guess the application would have to be running on the server.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          PrevInstance only works on the local machine, it will not work for what you're trying to do. You could give the users access to the other machines if you want to use the WMI route. Perhaps if we knew why you had to do this, we could offer alternate methods of achieving the same effect.

          Comment

          • wild123
            New Member
            • Aug 2012
            • 6

            #6
            Well the application was developed as a single user app and uses several ms access databases all on the same file server. Since then, we now have several people accessing the app but only one at a time over the LAN. (stand up and ask)
            Need to make this foolproof by not allowing the app to run if another person is using it.

            I rechecked and found that the database lock files (abc.ldb) also get deleted as soon as it crashes. so i should be able to check for presence of these files to open the app or not again.

            Need to create a dummy database, and load that as soon as the splash form is loaded and then again as the MDI form loads??????
            Let me try

            Comment

            • wild123
              New Member
              • Aug 2012
              • 6

              #7
              yay, done,
              loaded a dummy blank database on opening the application.
              check for presence of lock file, on found exit with message.
              and since it is a database, as soon as the application either closes or crashes, causes the lock file to be removed

              wonder why i did not think of this before.

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Don't rely on the lock file too much, that's not fool proof either. There are bugs that can cause the lock file to not get deleted. It should work most of the time though. And if the off chance risk is acceptable, then it should work for your purpose. I still don't understand why more than one person can't be in there at the same time.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  For an application that was written to be single-user, this sounds like a neat solution. Of course it would be nicer if users could "play nice" and share the database, but failing that, this should do the trick (mostly).

                  Comment

                  • wild123
                    New Member
                    • Aug 2012
                    • 6

                    #10
                    this started as a simple order entry and invoicing system which has since then grown into a full product management and reporting and order entry and invoicing and bill of materials application with over 10 separate databases with about 100 tables and dozens of forms and hundreds of reports.

                    Now the only way to get it multiuser is to completely rewrite the software.

                    The (mostly) part is fine as everybody in the office knows the single user thing. As for the lock file not being deleted, can be deleted manually on checking that the application is not open on any pc.

                    Lets hope this works in the long run

                    Comment

                    • Rabbit
                      Recognized Expert MVP
                      • Jan 2007
                      • 12517

                      #11
                      Access has support for multiple users without you having to do anything. What exactly happens if more than one person uses it at the same time?

                      Comment

                      Working...