Windows Batch File To Reset Remote Desktop Connection

Posted on 2009-04-30
Last Modified: 2012-05-06

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

Question by:palserv
    1 Comment
    LVL 67

    Accepted Solution

    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


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now