session - Batch Programming - comparing string -


i want perform action selected group of people tried writing batch command work in performing action group of people added if condition pick people begin string name. please find below code. somehow working.

setlocal enabledelayedexpansion  query session >session.txt  /f "skip=2 tokens=2," %%i in (session.txt) ( 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 multiple session myuser02,myuser03 , on

for /f "tokens=1,2*" %%a in ('qwinsta^|find /i "myuser"') (       logoff %%b ) 

may easier?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -