Jump to content

Logoff Certain user


mattw112
 Share

Recommended Posts

I know a million ways to initiate a logoff from the currently logged on user (shutdown(), shutdown.exe, dll's, etc...), but how would I logoff another user on the same system?

I need to uninstall software but I need to make sure no other users are logged onto the system. When there is another user I need to log them off then uninstall my software.

Any ideas?

Manually it is easy too. I can open task manager, go to the Users tab and select the user and right click and say logoff. I'd rather not do a bunch of sendkeys though if I can send a command line.

Thanks,

Terry

Edited by mattw112
Link to comment
Share on other sites

Use tsdiscon.exe..

tdiscon.exe from the microsoft website:

Tsdiscon disconnects a session from a terminal server. You must have Full Control permission to disconnect another user from a session.

If no session ID or session name is specified, tsdiscon disconnects the current session. The console session cannot be disconnected.

refer to this.

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

Hi.

rem Alle TS Sitzungen schliessen (close all TS sessions)
For /f "tokens=3" %%i in ('QWinSta ^| Find /i "aktiv" ^| find /i "rdpwd"') Do Echo y | RWinSta %%i

to close disconnected sessions, change "aktiv" (active) to whatever string represents disconnected sessions in you Window's language.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Thanks,

So I tried the TSDiscon...

It only disconnects the session it doesn't log off the user from the session.

But the query tool does let me know if that other user is logged on or not, which may be helpful.

Microsoft should just make it a command line feature of shutdown.exe. Using that tool you can do a logoff of the current session, would be easy to add a switch to specify the user session to log off?

Anyone else have any ideas on logging off other user sessions.

Also this isn't related to terminal services or remote desktop or anything. I just have a bunch of systems which may have multiple users logged on to them.

Thanks,

Terry

Link to comment
Share on other sites

Thanks,

So I tried the TSDiscon...

My example didn't use tsdiscon :), see below:

For /f "tokens=3" %%i in ('QWinSta ^| Find /i "aktiv" ^| find /i "rdpwd"') Do Echo y | RWinSta %%i

Also this isn't related to terminal services or remote desktop or anything. I just have a bunch of systems which may have multiple users logged on to them.

I use it with Win XP SP2 and 3. IIRC it's also fine for local sessions, pls check on your PCs, I never ever have multiple users logged into one workstatation.

Step by step:

QWinSta

what to search for (Find /i "aktiv")

optional: what to search for again, to narrow the results (find /i "rdpwd")

then the statement in red.

As another chance have a look at the options of shutdown() (autoit and windows)

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...