Programatically Reset All TS Sessions

  • Thread starter Thread starter Brian Williams
  • Start date Start date
B

Brian Williams

Guest
Does anyone have any suggestions (WMI or C# preferrably) on how to
programatically iterate through and disconnect all terminal services
sessions on a given server? As part of our patching process, we'd like to
do a mass reset on all active / disconnected sessions before kicking off a
patch, and a reboot just to accomplish this is a bit time consuming across
several hundred servers.
 
Re: Programatically Reset All TS Sessions

You could call WTSEnumerateSessions, then for each session call
WTSLogoffSession.

To call these from C#, see
http://pinvoke.net/default.aspx/wtsapi32/WTSEnumerateSessions.html and
http://pinvoke.net/default.aspx/wtsapi32/WTSLogoffSession.html

Rob

"Brian Williams" <brian@off-piste.org> wrote in message
news:850BEBDE-E1D5-4B6F-8848-D6BFAEB7BA33@microsoft.com...
> Does anyone have any suggestions (WMI or C# preferrably) on how to
> programatically iterate through and disconnect all terminal services
> sessions on a given server? As part of our patching process, we'd like to
> do a mass reset on all active / disconnected sessions before kicking off a
> patch, and a reboot just to accomplish this is a bit time consuming across
> several hundred servers.
 
Back
Top