943,012 Members | Top Members by Rank

Ad:
Mar 3rd, 2006
0

Disonnect remote users via Script on Terminal Services

Expand Post »
Hi all,

My client is running a Win 2003 SP1 Server with many users accessing it through Terminal Services. Every night I have some scripts to run that only run correctly if all users are logged off from Terminal Services.

I am wondering if it is possible to script the logoff of all remote users in Terminal Services? If so, could someone please point me in the right direction for doing this.

I didn't see anything in the previous posts about this but maybe I missed.

Thanks for your attention

Yomet
Similar Threads
Reputation Points: 16
Solved Threads: 10
Junior Poster
Yomet is offline Offline
134 posts
since Nov 2005
Mar 3rd, 2006
0

Re: Disonnect remote users via Script on Terminal Services

Hi all,

I found the answer, after correctly rephrasing my Google search... :o

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

Found at this URL:
http://winfaq.msterminalservices.org...=2&sortby=date

Sorry for wasting your time

Yomet
Reputation Points: 16
Solved Threads: 10
Junior Poster
Yomet is offline Offline
134 posts
since Nov 2005
Mar 4th, 2006
0

Re: Disonnect remote users via Script on Terminal Services

yea that's nice that they also tell you how to force console logoff.
Reputation Points: 70
Solved Threads: 19
Posting Whiz
antioed is offline Offline
335 posts
since Jan 2004
Mar 4th, 2006
0

Re: Disonnect remote users via Script on Terminal Services

antioed,

The logoff of Console is the one thing they say you cannot do with this. Do you have a method of doing that?

Thx

Yomet
Reputation Points: 16
Solved Threads: 10
Junior Poster
Yomet is offline Offline
134 posts
since Nov 2005
Mar 4th, 2006
0

Re: Disonnect remote users via Script on Terminal Services

whoops - you're right...they only say how to avoid the error message for the console session. i'm curious if a scheduled task would do it with the shutdown command right before your scripts run:

C:\Windows\System32\shutdown -l
Reputation Points: 70
Solved Threads: 19
Posting Whiz
antioed is offline Offline
335 posts
since Jan 2004
Mar 4th, 2006
0

Re: Disonnect remote users via Script on Terminal Services

I would also turn on the messenger service on the servers so I could script/schedule a broadcast a message to at least inform other admins that their session is going away. if you don't you're risking alarming your fellow admins unnecessarily. you could script with sc to enable/disable & start/stop messenger if you don't like having it run all the time. I would also use the same technique to shut down the TS service while running the scripts so nobody can login and interfere with your scripting requirements.


it's hard to find info about this because of the nature of console logins...this would only be admin users and thus normally you would never want to be kicking that kind of user out. obviously, you want your script to run, but something about blowing away admin sessions just doesn't sit right with me. i would at least let everyone know before i did that and also script in indicators so admins don't try to "fix" a problem which is really just your scripts doing their thing. for the console thing, to me, it makes more sense to request other admins not to leave stale console sessions, you know, use remote desktop only and broadcast a message to TS users five minutes before the force logoff of TS users runs.

another idea for the console thing, depending on number of servers you're running the script on, would be to use mstsc to log into the console session and check to make sure there's nobody logged in on the console before the script runs...this kinda defeats the point automating the tasks through scripting, though, since you'd have to login manually to do this.

mstsc /v <server: port> /console
Reputation Points: 70
Solved Threads: 19
Posting Whiz
antioed is offline Offline
335 posts
since Jan 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Windows NT / 2000 / XP Forum Timeline: Cant read IO.SYS
Next Thread in Windows NT / 2000 / XP Forum Timeline: lost my documents folder





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC