Windows Batch File To Reset Remote Desktop Connection


i have this command to reset desktop connection , i want this script to be run if i got msg max user exeded , the problem is the session got different ID each time .

so i need batch .BAT , to run this script and only put the ID # to reset

can anybody help??
net use /user:user\\server\share
query session /server:server
reset session # /server:server

Open in new window

Who is Participating?
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You do not need to use a share to connect to the server. IPC$ connection is sufficient.
set /P allows for user prompt, and stores the input into a environment variable (no here).

@echo off
net use \\Server /u:User Pwd
query session /server:Server
set /P no=No. of session to reset: 
reset session /server:Server %no%
net use \\Server /d

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.