I want to perform an action for selected group of people for this I am tried writing a batch command which work perfectly in performing action for all the group of people so I added a if condition which will pick only the people begin with that string name. Please find below the code. But it is somehow now working.
SetLocal EnableDelayedExpansion
query session >session.txt
for /f "skip=2 tokens=2," %%i in (session.txt) DO (
SET _prefix=%i:~0,6%
IF %_prefix%==myuser (
logoff %%i
)
)
del session.txt
EndLocal
Output of query session :
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
>console myuser01 1 Active
There can be multiple session like myuser02,myuser03 and so on