Disconnect VMwareView VDI session command line


Disconnect VDI session command line

This blog will show you how to setup an idle timeout for a VMware View environment to make sure sessions are disconnected after a certain idle time. 

Background

Several of our customers have redesigned their offices into flexible office where user roam from desk to desk. This offers great flexibility for users can work anywhere in the office and therefore work together with colleagues they don’t see that often. 
With modern office and a flexible concept less desks are available then before when everyone had a fixed location. The idea behind the concept is that only about 70% of all users are in the office at one time.
Users can be in a meeting for half a day or on the road. The idea behind the concept is that users disconnect their sessions before they go into a meeting and clear the desk for others. 
In practice we notices, our customers notice, that this desk releasing isn’t functioning. Users tend to forget to disconnect and the desk is left occupied.
This blog will show a simple way of ensuring that the desk is cleared after a certain idle time. 

Timeout variants

There are different stages where timing might be interesting.
  1. The first one is when the user has an open session in a VMware View VDI environment and he or she walks away from the desk. At this moment the idle timer starts ticking.
  2. The second one is when the session active and the user is either working or not active. This is the total time a session is allowed to exist
  3. The third and last one is when the session is disconnected. This disconnected stage of the session is allowed for a certain amount of time. Within that time frame the user can reconnect to the session, when that time frame has passed the session is logged of.

VMware View implementation

Session timeout

VMware View  has the option to set a global session timeout, this is a timeout to control what your maximum session length is. After the time you set your session is logged off. VMware View doesn’t have a idle timeout that controls if the session should stay active or become disconnected. 

Disconnect timeout

The disconnect timeout can be controlled by using group policies. VMware recommends using the Terminal servers policy settings for Sessions to control the disconnect timeout.
With this policy you can control how long a session will be left in disconnected state before it’s terminated. The other option with that policy is to set the timeout for the idle active session.
Despite what you might think this will not disconnect the session but will terminate it after the timeout has been reached.

Idle timeout

There is no idle timeout that will disconnect your session when a certain time has elapsed. To make sure idle sessions are disconnected after a certain time, to release a desk, is to create a scheduled task.
I have been searching for this for a while and haven’t found the perfect solution yet, I found a solution.. at least I think I did.

Task scheduling

I’ve been testing with a task schedule job to determine whether a session is idle. I was looking for a solution to determine this from within the session and not from the client side.
Of course it’s easier to check from a client side but then you are restricted to Windows clients.
So I created a Task schedule that would check for the idle status.
As a reference you can check this Microsoft reference: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383561(v=vs.85).aspx 

I created a task with the name “Idle timer” and selected “Run with highest privileges”.
The trigger I created is the task “on idle”.

The condition I set for this task is that it should wait  for 10 minutes and that it should stop counting when the user starts to work again.

When the condition is met and when the idle timeout has been met TSDISCON.EXE will start and disconnect the session. 
When this task is scheduled it will check every 15 minutes if the computer is idle. This is not an ideal situation but at this moment the best option I could think of.

Client side

From a client side the disconnect is easier to detect and control. Again a scheduled task can be created and when it detects the idle time it should close the connection. This closing of the connection can be done the hard way by using Taskkill to kill the VMware View client process called wswc.exe. Once that one is killed the session is disconnected automatically.
The command for this would be Taskkill /im wswc.exe and this could be entered in the same line as above in the task scheduler in the action pane.
This is the easiest way but will only work on a Windows client.

Conclusion

It’s pretty weird that VMware doesn’t offer a setting to establish a disconnect of a session. I found that this setting worked in my lab environment but have to test it in a live environment. 
Hope this blog will help you setup a idle timeout….
If you think you have a better solution please let me know I’m very interested.

1 Response

  1. Chris says:

    Did you find any robust solution for disconnecting idle pcoip sessions?

Leave a Reply

https://tracking.cirrusinsight.com/869c29e2-3a9b-48c5-9232-0b95e7993ae8/controlup-com-pixel-php