Search code examples
windowsbatch-fileauthenticationlogoutwinlogon

Batch File: Need conditional script that would log out any user apart for me


I am looking for some help.
I am looking to create a local logon script on Local GPO on my desktop.
What I need to do is, when any user logs in, this script will fire and check the currently logged in user, and if it's not my account then it would logoff.

Something like:

IF NOT %username% = Domain\me shutdown.exe -l

Any other solutions also accepted.


Solution

  • what's you are looking is HELP IF

    The syntax should look like:

    @echo off
    
    rem add your username here after the = without space.
    set "_MyUsername=MyUsername"
    
    if [%username%] neq [%_MyUsername%] shutdown.exe /l /f || exit /b 0