none
log off other user accounts in Windows via batch script (.bat) RRS feed

  • Question

  • log off other user accounts in Windows via batch script.

    Unable to logoff ID of other user using below script,  it just  run continuous , need assistance.

    Script 

    query session
    logoff 1
    pause


    Tuesday, July 2, 2019 7:14 PM

All replies

  • Hi,

     

    If possible, please take a screenshot for the error and upload the images in our forum directly so that I can do further analysis based on the error.

     

    The scripts run with users standard privileges, it might need to run as administrator.

     

    For your reference:

    https://www.tenforums.com/user-accounts-family-safety/118389-log-off-all-but-current-user.html

    Note: This is a third-party link and we do not have any guarantees on this website. And Microsoft does not make any guarantees about the content.

     

    Hope above information can help you.


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, July 3, 2019 2:09 AM
  • Script 

    "query session
    logoff 1
    pause"

    Batch file execute : 

    C:\Users\USER\Desktop>query session
     SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
     services                                    0  Disc
    >console           USER                      1  Active

    C:\Users\USER\Desktop>logoff 1

    C:\Users\USER\Desktop>query session
     SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
     services                                    0  Disc
    >console           USER                      1  Active

    C:\Users\USER\Desktop>logoff 1

    -----------------------------------------

    In this way it keeps on repeating instead of logoff 1 (ID) 

    Wednesday, July 3, 2019 5:53 PM
  • Wednesday, July 3, 2019 11:12 PM
  • Hi,

     

    Any update? Please let us know if you need more help.


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, July 8, 2019 6:52 AM