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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
This should do it.

for /f "tokens=3" %%a in ('qwinsta %username% /server:myservername ^| find /i "%username%"') do rwinsta %%a /server:myservername

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bytes100Author Commented:
Awesome - thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.