• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 650
  • Last Modified:

Determine who is executing a winform application on fileserver

Hello experts,

We have deployed some winform application to a fileserver.
The exe files are copied to the fileserver and many clients execute them directly from the fileserver via a shortcut.
Our problem is when we try to release new versions, we have to find
every client that is executing the apps, tell them to close and only then we can release the new version.

Is there a way to receive the list of clients using a certain file, in the same way
I can receive it when managing open files via MMC?

We tried many ways, including Netapi32.dll, WMI etc.
I thought maybe there is a simple way to determine if a file is locked and receive the client that are locking the file.

Thanks in advance,
OZ
0
oferz
Asked:
oferz
  • 4
  • 2
1 Solution
 
TommySzalapskiCommented:
The exe should show up as an open file. On Windows Server 2008, in 'Server Management' I go to 'Roles'->'File Services'->'Share and Storage Manager' and click 'Manage Open Files...' and the exe files are there in the list.
0
 
TommySzalapskiCommented:
Whatever OS you are using, it should be in the shared file management thing, wherever that is.

We actually avoid that issue entirely to where we can roll out updates without worrying about who has what open.

The directory looks something like this
program-v1.1.exe
program-v1.2.exe
program-v1.3.exe
program-v2.0.exe
program.exe

All program.exe does is search the directory for the latest version and then run it. So we can just drop updates in since we don't overwrite the old versions. Also if program.exe needs updating (rare) it's not a problem since it's never open for more than a few milliseconds.

The only downside is you do run the risk of someone using the old version for days if they don't log out or shut down their computer overnight.
0
 
oferzAuthor Commented:
Thanks Tommy,
We tried the solution that you are using.
Some of the application must be open all the time, logging, birocracy issues, long story...
We have to make sure the clients close all the exe files and then replace them with the new version.
So I'm looking for a .net function to receive all the users holding the file.

Thank you for the quick reply.
Ofer
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
TommySzalapskiCommented:
Oh okay. I get it. You're basically looking for a .NET API into the shared file administrative tool, right?
0
 
TommySzalapskiCommented:
As far as I know (and from looking it up some more just now) there isn't anything built in to do it. The way ProcessMonitor and the like do it is by loading a dynamic device driver (complicated). Why do you want to do it from .NET instead of the Server Management tool?

The easiest way would probably be to track who has it open yourself. Write the form such that it logs when it's opened and by whom (Have you used environment variables? They are easy.) That way you can do it without any complex mumbo-jumbo.
0
 
Todd GerbertIT ConsultantCommented:
It sounds like this particular application would benefit greatly from ClickOnce. It's not a particular good idea to publish an application in the manner that you are, if for no other reason than what you've just described and likely others.

ClickOnce Deployment: http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.90).aspx

It's intended specifically for the exact scenario you've just described, and makes updating your application a piece of cake.
0
 
oferzAuthor Commented:
I was interested in the solution as I described above because we use several application in the same way. If I would find a way it would make our life easier for all our application at this customer.
Just to let you know my progress so far, I found a way to show all shared folders at the file server, on one of this shared folder is all our exe files. The server does not execute the files as a service so they won't apprear in the process list but they should appear as open files like in the manage open files / sessions. Any way just to share with you my progress so far:

            Dim searcher As Management.ManagementObjectSearcher '("SELECT * FROM Win32_ConnectionShare")
            searcher = New Management.ManagementObjectSearcher("\\" & txtServerName.Text & "\root\cimv2", _
            "SELECT * FROM Win32_ConnectionShare") 'Win32_ConnectionShare") 'SELECT * FROM Win32_Share
            For Each connectionShare As Management.ManagementObject In searcher.[Get]()
                ' Win32_Share
                Dim antecedent As String = connectionShare("Antecedent").ToString()
                Console.WriteLine("Antecedent: " + antecedent)
                Dim share As New Management.ManagementObject(antecedent)

                ' Win32_ServerConnection
                Dim dependant As String = connectionShare("Dependent").ToString()
                Console.WriteLine("Dependant: " + dependant)
                Console.WriteLine(vbLf)
            Next

Thank you anyway,
Ofer
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now