Batch Processing automatically disconnects the Internet shared access

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 ).

@ 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.