none
batch script to log off a user in windows 8.1 core RRS feed

  • Question

  • Hello Mates!

    I've got windows 8.1 core edition running on a compaq machine. I created a few accounts on it. Normally when I want my child to log off I log into my account (I'm an admin). Run the taskbar, go to users tab, rightclick my child's username and choose the signoff action.

    I want to automate this process. How do I execute the above actions from a command prompt? As I've got just the core edition of windows, remote desktop commands do not work. Also, the commands like 'query user', 'logoff.exe 1', etc. are not recognised. Am I missing any windows feature that I need to activate?

    Thanks!

    -Gamma

    Tuesday, December 30, 2014 5:18 PM

Answers

  • I did it !

    I did it !!

    I didit didit didit !!!

    simple command :

    Get-TSSession -UserName <the username goes here> | Stop-TSSession -Force

    But I had to install Terminal Services Module as described here : http://psterminalservices.codeplex.com/

    The TS Module is intended for RDP usage. However, it works just fine for local user sessions! :-)

    And yes, I needed to run the command from a powershell instead of the command prompt. When I put the command in a .ps1 batch file, that gave me another problem. The batch file should be run from elevated powershell. Or else you get an access denied error.

    As I am already an admin on my own pc, I got a workaround code here : http://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator/17888599#17888599

    Hunky dory! :-)

    Thank you Bill Stewart and jrv for your patience and tolerating my ignorence.

    -Gamma


    Sunday, January 4, 2015 5:59 PM

All replies

  • For home user quesitons you shoud  post here: http://answers.microsoft.com/en-us

    The tool is called "shutdown".  Look at the help.


    ¯\_(ツ)_/¯

    Tuesday, December 30, 2014 5:38 PM
  • Thanks jrv for further pointer. :-)

    Actually I came here from that forum itself. I've raised this problem there : http://answers.microsoft.com/en-us/windows/forum/windows8_1-performance/batch-script-to-log-off-user-in-windows-81-core/44740332-ac73-4c23-9f1d-07f30c5541a7

    They directed me here.

    Yes, I tried the shutdown command with /l option. But that logs me off rather than others!

    Thank you once again!

    -Gamma


    • Edited by Gamma.577 Wednesday, December 31, 2014 10:55 AM additional info
    Wednesday, December 31, 2014 10:46 AM
  • Also, the commands like 'query user', 'logoff.exe 1', etc. are not recognised.

    Please be more specific about what this sentence means. Do you get an error message? How are you running the commands? (etc.)


    -- Bill Stewart [Bill_Stewart]

    Wednesday, December 31, 2014 5:04 PM
    Moderator
  • Hello Mates!

    I've got windows 8.1 core edition running on a compaq machine. I created a few accounts on it. Normally when I want my child to log off I log into my account (I'm an admin). Run the taskbar, go to users tab, rightclick my child's username and choose the signoff action.

    I want to automate this process. How do I execute the above actions from a command prompt? As I've got just the core edition of windows, remote desktop commands do not work. Also, the commands like 'query user', 'logoff.exe 1', etc. are not recognised. Am I missing any windows feature that I need to activate?

    Thanks!

    -Gamma

    These commands do notork with WIndows Hime versions.  They are avaiable in Pro, Enterprose and Ultimate I believe.

    You might be able to use psloggedon at http://www.sysinternals.com

    There is no scripting answer to your quesiton and this is not a forum for utilities support for home users.  "answers" is the place if you ask the correct question.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, December 31, 2014 5:18 PM
    Wednesday, December 31, 2014 5:11 PM
  • Note that ther eis no 8.1 "core"  it is either 8.1 Home, Home Premium, Pro, Enterprise.

    WS2012 core is the version of 2012 with no GUI installed by default.

    Windows 8 Core designation is a feature set.  It is - I guesss - the new designation for "Home" after 8.0 is gone.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, December 31, 2014 5:18 PM
    Wednesday, December 31, 2014 5:14 PM
  • I am not sure how "core" gets into it.  Her is theMS documentaaion on the compared features of WIndows 8.1 version--- no "CORE":

    http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/windows-8-1/compare/default.aspx

    What some are calling "core" is just Windows 8.1. THis is part of the drive by MS to have a singlecodebase for all systems.

    If you upgraded from Win 8 Hometo Win 8.1 thenyou willlikely be missing some features.


    ¯\_(ツ)_/¯

    Wednesday, December 31, 2014 5:21 PM
  • Hi,

    I would suggest looking at the Win32Shutdown method.

    See here for reference - http://msdn.microsoft.com/en-us/library/aa394058%28v=vs.85%29.aspx

    Thanks

    Sam.

    Friday, January 2, 2015 3:19 PM
  • Hi,

    I would suggest looking at the Win32Shutdown method.

    See here for reference - http://msdn.microsoft.com/en-us/library/aa394058%28v=vs.85%29.aspx

    Thanks

    Sam.

    It only logs off the currentconsole user same as shutdown.

    ¯\_(ツ)_/¯

    Friday, January 2, 2015 3:22 PM
  • Hello Bill Stewart,

    >>  Do you get an error message? How are you running the commands?

    I tried these commands from elevated command prompt :

    logoff
    quser
    qwinsta

    for all these I got this error :

    'logoff' is not recognized as an internal or external command,
    operable program or batch file.

    I didn't find qwinsta.exe in c:\windows\system32. I tried to locate it on the c: drive. I found it at
    "C:\Windows\WinSxS\amd64_microsoft-windows-t..commandlinetoolsmqq_31bf3856ad364e35_6.3.9600.16384_none_19e7d16c7ffc24f6\qwinsta.exe"

    Since it's found in winsxs folder, I guess it belongs to some suppressed feature. I understand that I might be wrong.

    Thank you!
    -Gamma
    Friday, January 2, 2015 8:28 PM
  • Hello jrv,

    >> Note that ther eis no 8.1 "core"  it is either 8.1 Home, Home Premium, Pro, Enterprise.

    The official name is 'Windows 8.1 with Bing' obtained from Control Panel\System and Security\System. It's oem supplied, not upgraded from win 8.0. As it's a basic edition, the rdp suite of commands is not supported.

    Thank you! :-)
    -Gamma
    • Edited by Gamma.577 Friday, January 2, 2015 8:30 PM
    Friday, January 2, 2015 8:30 PM
  • Those utilities are only available on the Pro or greater versions.  Upgrade to Pro and you will have them.  A Pro upgrade is mostly a license that enables many featires.

    Logoff does not exist on Windows 8.

    I recommend using PsLoggedOn.  It is free and does what you want.


    ¯\_(ツ)_/¯


    • Edited by jrv Friday, January 2, 2015 8:44 PM
    Friday, January 2, 2015 8:38 PM
  • Hello jrv,

    >> Note that ther eis no 8.1 "core"  it is either 8.1 Home, Home Premium, Pro, Enterprise.

    The official name is 'Windows 8.1 with Bing' obtained from Control Panel\System and Security\System. It's oem supplied, not upgraded from win 8.0. As it's a basic edition, the rdp suite of commands is not supported.

    Thank you! :-)
    -Gamma

    Windows 8.1 "core" or, as Microssft calls it "Base" is without RDS and the RDS tools like quser and qwinsta.  YOu must upgrade to Pro or better to get these utilities.


    ¯\_(ツ)_/¯

    Friday, January 2, 2015 8:40 PM
  • I upgraded an 8.1 Base VM to Pro and all utilites are installed and LOGOFF works.

    If you don't want to upgrade then download PsLoggedOn.  It is free and does not need to be installed.  It is a coomandline utility:

    http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx

    I am sorry but PsLoggedOn cannot yest log off a user.


    ¯\_(ツ)_/¯


    • Edited by jrv Friday, January 2, 2015 8:55 PM
    Friday, January 2, 2015 8:52 PM
  • I did it !

    I did it !!

    I didit didit didit !!!

    simple command :

    Get-TSSession -UserName <the username goes here> | Stop-TSSession -Force

    But I had to install Terminal Services Module as described here : http://psterminalservices.codeplex.com/

    The TS Module is intended for RDP usage. However, it works just fine for local user sessions! :-)

    And yes, I needed to run the command from a powershell instead of the command prompt. When I put the command in a .ps1 batch file, that gave me another problem. The batch file should be run from elevated powershell. Or else you get an access denied error.

    As I am already an admin on my own pc, I got a workaround code here : http://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator/17888599#17888599

    Hunky dory! :-)

    Thank you Bill Stewart and jrv for your patience and tolerating my ignorence.

    -Gamma


    Sunday, January 4, 2015 5:59 PM
  • Yes - direct API calls would work.  That is also a nice TS mmanagement module based on Cassia DLL project which I had seen a couple of years ago.


    ¯\_(ツ)_/¯

    Sunday, January 4, 2015 6:30 PM
  • Hi jrv,

    Windows allows me to take a certain admin action. But discourages me from executing it as a batch. Isn't it strange? Aren't computers made for automating our mundane jobs?

    -Gamma

    Sunday, January 4, 2015 7:23 PM