To automatically disconnect batch code from a network share access connection _dos/bat

Source: Internet
Author: User
Tags goto
Applicable platform: WINDOWS 2k/xp Home/pro

Applicable environment: directory sharing or Printer sharing, often due to the maximum connection of 10 people, and can not provide normal file and print sharing services to others

Workaround:

1, Pro version of the system, modify Group Policy secpol.msc/Local Policy/security options/The time required before suspending the session, change to 1 minutes
2, use the following script, every 30 seconds (or custom interval) to clear access to the connection
Copy Code code as follows:
@echo off
REM defines the cycle interval:
Set secs=30
Echo.
echo ============================================
echo = = = This script automatically disconnects some access when it is up to the upper limit of computer share access and uses = =
Echo = = To run a script = =
Echo = = Query for every%secs% of seconds, and perform purge command = =
Echo ============================================
Echo.
Net session >nul | | goto:error
: BEGIN
Set clear=0
Echo.
for/f "tokens=1,2"%%i in (' Net sessions ^| find '/') does (
net session%%i/delete/y >nul 2>&1 >set clear=1
Echo%time:~0,8% clear Access Source:%%i [%%j]
)
Echo.
If%clear%==0 (the Echo%time:~0,8% now has no access to this computer,%secs% seconds later ...
) Else (Echo%time:~0,8% cleared,%secs% seconds later ...)
Ping 127.0.0.1-n%secs%-W 0 >nul 2>&1
Goto begin

: Error
Echo permissions are not sufficient to perform, please contact your administrator.
Echo.
Pause >nul 2>&1 |echo Please press any key to close ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.