?
Solved

Remotely logoff users from terminal server

Posted on 2009-07-08
4
Medium Priority
?
596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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