Some Windows installations (like upgrading Windows Server 2008 R2 to Windows Server 2012) will not let you upgrade if there is a user logged on the machine. Even if the user is disconnected, the upgrade will not take place.
Easy enough, you think, I only need to bring up the Task Manager, switch to Users and click Disconnect:

Disconnecting a user using Task Manager
Unfortunately, after selecting Log Off, I always get this error regardless of the fact that I am an administrator:

Denied!
The only way I’ve managed to disconnect the user is using the command prompt.
First, type qwinsta to see the list of sessions:

This helps us find the ID of the user we want to disconnect
Now we simply issue the command rwinsta followed by the ID of the user:

Success!
For more info on connecting to remote sessions, please visit the source URL:
http://www.techtalkz.com/blog/tips-n-tricks/how-to-view-disconnect-remote-desktop-sessions-from-commandline.html
Christian Saborio
Christian is a seasoned computer engineer with a rich career spanning collaborations with industry leaders such as Artinsoft (now Mobilize.net), Microsoft, HP, and Intel. As a technical evangelist and trainer, Christian honed his expertise in Costa Rica and Seattle, delivering impactful solutions and sharing his knowledge.
Now based in Sydney, Australia, Christian channels his passion into web development, leading a talented team to tackle diverse projects with innovation and precision. His commitment to crafting exceptional digital experiences reflects his deep-rooted enthusiasm for technology and problem-solving.
Rudi says:
Thank you, thank you and 1000 times more, thank you