Solved

Remotely logoff users from terminal server

Posted on 2009-07-08
4
591 Views
Last Modified: 2012-05-07
Hi,

We have several terminal servers, all servers are windows 2003. I want to log off the users remotely from the terminal servers, so that the profiles are cleaning from the terminal servers. I have tried it with the query session command and then the logoff-command from the domain controller. But then I must hit a key to continue. I have also tried logoff /f, but it doesn't work.

Does anyone know the solution???
0
Comment
Question by:kvwestbroek
4 Comments
 
LVL 13

Expert Comment

by:jaynir
ID: 24809984
first you have to query the users that are logged on. you can use qwinsta /server:<servername>

this will show you the username and the ID of the session. Once you know the user who's logged in,
you can use logoff command that will log off the user.
type logoff <session ID>/server:<servername>
0
 

Accepted Solution

by:
kvwestbroek earned 0 total points
ID: 24811677
Jaynir,

If I use the logoff command I must hit a key to complete this. Here you can find my script:

query session /SERVER:PTSTEST > session.txt
for /f "skip=2 tokens=2," %%i in (session.txt) DO logoff %%i /SERVER:PTSTEST
del session.txt

I will put this script in the task manager and run it at night.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question