How to Disconnect Ghost FileMaker Sessions on Your Server

By October 12, 2017 9 Comments

What are Ghosts Sessions?

When you lose your network connection or your FileMaker quits, sometimes your session doesn’t drop off on the FileMaker server. This becomes a problem when that session hogs up one of your license spots. This doesn’t seem to happen often, but when I talked prentices to colleagues at the annual FileMaker Developer Conference, I learned it happens more often than we think.

The Process to Eliminate Ghost Sessions

So, once we identify we have a problem, we can start cooking up a solution. This particular server happens to be Windows Server. First I thought about VB scripting or Power Shell scripting. To be honest I’ve written one small Power Shell script, but this seemed a little above my head. So, I thought, well, here’s a tool I know how to use: FileMaker. I wonder if it can do the job. It can, indeed.

The process is basically the following:

  1. Issue a command in Command Line to get a list of connected clients;
  2. Create records in a table;
  3. Compare them to see which ones are the same (same IP address or user);
  4. Issue a disconnect for everyone except for the newest connection.

So how do we do this from FileMaker? With the use of a plug-in, of course. In this case I grabbed the Base Elements plug-in, because it was already installed on the server.

The Base Elements plug-in can issue Command Line commands. I use it to get the list of connected clients:

BE_ExecuteSystemCommand ( “fmsadmin list clients -s -u <username>r -p <password>” )

The result comes back in fixed-width text format — which gave me a little headache, but I learned a lot from it. Fixed-width means that every word has a certain amount of space and the data is separated by an indeterminable number of spaces. To get that data into arrays, you have to calculate the position of the column headers.

Let (


text = GetValue ( $BE_output ; 1 ) ;

$$pID = Position ( text ; "Client ID" ; 1 ; 1 );

$$pUname = Position ( text ; "User Name" ; 1 ; 1 ) ;

$$pCname = Position ( text ; "Computer Name" ; 1 ; 1 ) ;

$$pCon = Position ( text ; "Connect Time" ; 1 ; 1 ) ;

$$pDur = Position ( text ; "Duration" ; 1 ; 1 )


$$pID  & ¶ &

$$pUname  & ¶ &

$$pCname  & ¶ &

$$pCon  & ¶ &



I then go through the result and create records from it. Now I have records to compare the timestamp on the similar records.

The way I do that is by setting up another table occurrence (user = user in my case) and then checking whether the record is a duplicate via this calculations:

TimeStamp ≠ Max ( UT__UtilityTable_User::TimeStamp )

Here is my table:

Utility Table

Utility Table

Expand image

Disconnecting the Ghost Sessions

The last thing is to find the records that are marked duplicate and then loop through to issue a disconnect command for them:

# Loop through the dups and disconnect 

Go to Record/Request/Page [ First ]

Set Variable [ $rep; Value:1 ]

Set Variable [ $maxReps; Value:Get (FoundCount) ]

# Disconnect the client(s) 
Set Variable [ $ID; Value:UT__UtilityTable::ID ]

Set Variable [ $command; Value:"fmsadmin disconnect client " & $ID & " -y " & " -u " & $username & " -p " & $password ] 
Set Variable [ $BE_output; Value:BE_ExecuteSystemCommand ( $command ) ]

Set Variable [ $error; Value:BE_GetLastError ]

If [ $error > 0 ] 
Send Mail [ Send yourself an email via SMTP so you know when there was a user disconnected.][ No dialog ]
End If 

Exit Loop If [ $rep = $maxReps ]

Go to Record/Request/Page [ Next ]

End Loop 

As you can see I’m using username and password variables above. Those are set in my script with the FileMaker Admin console access values I need to issue the command line commands.

Following these steps should help you eliminate ghost sessions in FileMaker and avoid overusing unnecessary license spots. Good luck! If you have any questions, let me know in a comment below or contact my team directly.

Agnes Riley

Agnes Riley

Agnes is a Senior Application Developer, and a jack of all trades, master of none. While she mostly enjoys crafting pretty things and integrating different technologies, she is equally a fan of helping clients with data parsing from Excel to FileMaker. When she is not chained to her MacBook Pro, she can be found hanging off a rope in an indoor climbing gym or holding onto the handlebars on her red and white motorcycle.


  • Avatar Nick Stockbridge says:

    This is a fantastically useful article. The problem has definitely happened to me. Thanks very much for this tip.

  • Thanks, Agnes! This one is going in the tool chest.

  • Avatar xjohn renfrew says:


    This doesn’t work… I have added cmd.exe /c to the start as per the BaseElements help but it just creates a ghost session of its own that refuses to disconnect and locks up the calling FileMaker file

    • Dawn Heady Dawn Heady says:

      I’m sorry that FileMaker Server did not respond to the command. Just as FileMaker Server might not respond to a command you initiate from the Admin Console, so too might be the case with the command line. In that case I recommend using the Admin Console (or command line) to close all the hosted files, stop FileMaker Server, restart the server computer, and then restart FileMaker Server, if it is not set to do so automatically on startup.
      Best of Luck,

  • […] Source: How to Disconnect Ghost FileMaker Sessions on Your Server […]

  • Avatar Paul Human says:

    Thank you, this works really well. However, fmsadmin does not appear to have an option for disconnecting without the user’s agreement. I am implementing a system which would request a user, who has logged in on more than one device, to log out on the other device. As such, the user will likely not be available to agree to the request on the more distant device. Is there any way to do this?

Leave a Reply

Need to adjust your business processes quickly? We're helping clients use technology to keep their teams productive and running smoothly in these times of uncertainty. Our team can guide yours if you need help in these areas.

Talk to a Consultant