How to realize the batch processing of automatically disconnecting the access connection of network shares
This article is about how to implement batch processing that automatically disconnects access to network shares. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Applicable platform: WINDOWS 2K/XP HOME/PRO
Applicable environment: directory sharing or printer sharing, often unable to provide file and print sharing services to others due to reaching the connection limit of 10 people
Solution:
1. Pro version system, modify group policy secpol.msc/ local policy / security option / time required before suspending session to 1 minute
2. Use the following script to clear access connections every 30 seconds (or custom intervals)
The code is as follows:
@ echo off
Rem defines the cycle interval:
Set secs=30
Echo.
Echo =
Echo = = this script is used after the computer share access limit is reached = =
Echo = automatically disconnects some access connections after running the script = =
Echo = = query every% secs% seconds and execute 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 one is currently accessing this computer,% secs% seconds to continue.
) else (echo% time:~0,8% cleared,% secs% seconds to continue.)
Ping 127.0.0.1-n% secs%-w 0 > nul 2 > & 1
Goto begin
: error
Echo is not authorized to execute, please contact your administrator.
Echo.
Pause > nul 2 > & 1 | echo, please press any key to close.
Thank you for reading! This is the end of the article on "how to automatically disconnect the batch of network sharing access connections". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!