rwinsta bat file to clear citrix sessions

Hi all.
Im  looking to create a bat file to reset a users citrix session. Ideally Id like any user to be able to click a link to the bat file and their citrix session will clear.

So far ive come up with the following commands

qwinsta %username% /server:myservername
set /p id=enter ID to clear session :
echo %id%
rwinsta %id% /server:myservername

This works fine, but im wondering if theres a way to automate the whole process without them having to enter the ID?
Who is Participating?
AmazingTechConnect With a Mentor Commented:
This should do it.

for /f "tokens=3" %%a in ('qwinsta %username% /server:myservername ^| find /i "%username%"') do rwinsta %%a /server:myservername
If the user is resetting themselves, %username is the variable you want.
bytes100Author Commented:
Hi and thanks for the quick response.

Im aware i need to use %username%, however, I need the actual entire code for this.

i think im looking to take ID from qwinsta and pipe it to the rwinsta part.
bytes100Author Commented:
Awesome - thank you!
All Courses

From novice to tech pro — start learning today.