RDP Exit with Log off Windows 7

Hello Experts,

Can someone let me know if its possible to have an RDP session log off when exiting?

For example, if you exit by clicking the 'X' as shown in the image below

You will get the following:
However, this doesn't log users off when from a RDP session. I need to either prevent users from using the 'X' or ensuring that using the 'X' results in users logging off.

If neither of the above is possible then a message box which tells users to 'log off' instead.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HowardPMANetwork AdministratorCommented:
If you press the Start button, and go to Windows Security (second column on the right) you will have the option to logout, or restart.
cpatte7372Author Commented:

I don't think you understood me. I'm trying to figure out a way of ensuring that users are logged of when they click the 'X' shown in the image, rather than just being disconnected from the remote session....
HowardPMANetwork AdministratorCommented:
Instead of exiting by pressing the x in the RDP bar, you can exit via Windows Security in the RDP session.

Alternatively, you could write a batch file placed on the Public Desktop with the shutdown -l -f -t 3 for 3 second delay. This would log them off. When they log off, the session is killed.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

cpatte7372Author Commented:
Yeah, but there will always be users that will click 'X' and the disconnect the session :-( I'm trying to prevent that or a way of ensuring that for those users that click 'X' an alternative occurs
HowardPMANetwork AdministratorCommented:
Ah. As Ron White said, "There ain't no cure for stupid."
NVITEnd-user supportCommented:
You can probably use these together:
query session /server:Server64

Open in new window

reset session rdp-tcp#6

Open in new window

Spike99On-Site IT TechnicianCommented:
We had the same problem.  To resolve, we put a shortcut on the user's desktop to "logoff.exe" and changed the icon to something like the MSN butterfly:
Screenshot of Shortcut to Logoff.exe
We just notified users to never use the "X" to close their remote desktop window: we told them to use the butterfly instead.

If this were a terminal server, you could use TSConfig to configure session time out settings, but that's not possible in Windows 7. You have to either edit the registry or use group policy (or local policy) to implement that change.

I would not set the time out period too low because I wouldn't want users to lose work if they were disconnected due to a connection problem & not because they clicked on the "X."

This page describes how to set up time outs for remote sessions in Windows 7 & 8 using local policy settings (domain level group policy settings would be similar):
NVITEnd-user supportCommented:
I forgot to mention the use of my post http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_28672870.html#a40775465

Use it when users forget to use the other expert suggestions and use the "X" anyway.
cpatte7372Author Commented:
Thats great,

I don't know who to reward the points to?
Spike99On-Site IT TechnicianCommented:
I would award points to the Expert whose response helped the most.  You can award points to any Experts who helped by giving them points for assisting.
cpatte7372Author Commented:

I tried the suggestion from the link you provided, but no luck.

Can you let me know what I might be doing wrong?

Spike99On-Site IT TechnicianCommented:
The screenshot you posted is for the idle session limit.  If you set the idle limit to one minute, that means users will have their idle sessions disconnected after just 60 seconds.  So, getting a cup of coffee or turning away from their PC to take a phone call could result in their sessions being disconnected.  So, they will constantly have to reconnect to their disconnected sessions: users will find that to be very annoying.

So, I would set the idle session limit to disconnect users after more like 60 minutes.

I think the policy you are looking for is the one to "Set time limit for disconnected sessions" which will end a disconnected session after a given amount of time.  I would set that policy to 30 or 60 minutes, not just 1 minute.  If you set that disconnected session limit too low, users who are getting dropped due to connection issues will be constantly losing unsaved work: you'll get phone calls or emails about it.

This technet page has some information about what those different policies do:

This is the link I posted before with info on how to set idle time limits for Windows 7 using both local policy & group policy:

That SevenForums.com page doesn't have a screenshot for the "Set time limit for disconnected sessions" policy but that one works very much like the idle time limit policy. You enable it & then set the limit.
The key difference is: the "set time limit for idle sessions" will disconnect an idle session after the specified amount of time.  While the "set time limit for disconnected sessions" will end a disconnected session after the specified amount of time.

Here's a screenshot of that "set time limit for disconnected sessions" local policy setting from my own Win7 PC:
Screenshot of Disconnected Time Limit Policy Settings
I hope this clarifies things for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cpatte7372Author Commented:
Hi Alicia,

Thanks for responding. I'm trying to get the RDP session run a batch file when an RDP session starts by configuring the session as shown in the image, but it won't run the batch file when a new session starts.

Any thoughts?
cpatte7372Author Commented:
Spike99On-Site IT TechnicianCommented:
I've never tried to use that particular GPO setting.
I would just put the shortcut to the BAT file in the STARTUP folder on the server: that way it will run whenever a user logs on.  I believe the path for that in Windows Server 2012 hasn't changed since Server 2008/Windows 7:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

I hope this helps.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.