Batch code for automatically disconnecting the Internet shared access connection

Source: Internet
Author: User

Applicable platform: WINDOWS 2 K/xp home/PRO

Applicable environment: Directory sharing or printer sharing. Files and print sharing services cannot be provided to others due to the connection limit of 10 users.

Solution:

1. In the PRO version, modify the Group Policy secpol. msc/Local Policy/security options/the time required before the session is suspended to 1 minute.
2. Use the following script to clear the access connection every 30 seconds (or custom interval ).Copy codeThe Code is as follows: @ echo off
Rem defines the cycle interval:
Set secs = 30
Echo.
Echo ===================================================== =====
Echo = This script is used when the computer shared access reaches the Upper Limit =
Echo = some access connections are automatically disconnected after the script is run =
Echo = query every % secs % seconds and run the clear command =
Echo ===================================================== =====
Echo.
Net session> nul | goto: error
: Begin
Set clear = 0
Echo.
For/f "tokens = 1, 2" % I in ('net session ^ | find "/" ') do (
Net session % I/delete/y> nul 2> & 1
Set clear = 1
Echo % time :~ 0, 8% clear access Source: % I [% j]
)
Echo.
If % clear % = 0 (echo % time :~ 0, 8% no access to this computer, % secs % seconds later continue...
) Else (echo % time :~ 0, 8% cleared, % secs % seconds later ...)
Ping 127.0.0.1-n % secs %-w 0> nul 2> & 1
Goto begin

: Error
The echo permission is insufficient and cannot be executed. Contact the administrator.
Echo.
Pause> nul 2> & 1 | press any key to disable echo...

Related Article

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.