Automatically detect all disks and then delete the batch of default shares for all partitions

Time:2021-9-3

Delete the default share. Bat for all partitions

Copy codeThe code is as follows:
@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
::       List the existing partitions, and then delete the shares named by the partition name one by one;
::       Prevent the admin $share from reloading at the next boot by modifying the registry;  
::       IPC $share needs administrator permission to be deleted successfully
::
::                               jm   Change in   2006-5-12
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

title   Default share remover
echo. 
echo —————————————————— 
echo. 
echo   Start deleting the default share under each partition  
echo. 
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do @(
    if exist %%a:\nul (
         net   share  %% a$  / delete>nul   2>nul  &&  echo   Successfully deleted the file named  %% a$   Default share for  ||  echo   be known as  %% a$   The default share for does not exist
    ) 
)
net   share   admin$  / delete>nul   2>nul  &&  echo   Successfully deleted the file named   admin$   Default share for  ||  echo   be known as   admin$   The default share for does not exist
echo.
echo —————————————————— 
echo.
net   stop   Server>nul   2>nul  &&  echo   Server service stopped
net   start   Server>nul   2>nul  &&  echo   Server service started
echo. 
echo —————————————————— 
echo. 
echo   Modify the registry to change the system default settings  
echo. 
echo   Creating registry file  
echo Windows Registry Editor Version 5.00> c:\delshare.reg 
::   Disable admin $sharing through the registry to prevent it from loading again after restart
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]>> c:\delshare.reg
echo “AutoShareWks”=dword:00000000>> c:\delshare.reg 
echo “AutoShareServer”=dword:00000000>> c:\delshare.reg 
::   Delete the IPC $share. This function requires administrator permission to delete it successfully
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]>> c:\delshare.reg
echo “restrictanonymous”=dword:00000001>> c:\delshare.reg
echo   Importing registry file to change system default settings  
regedit /s c:\delshare.reg 
del   c:\delshare.reg  &&  echo   The temporary file has been deleted  
echo. 
echo —————————————————— 
echo. 
echo   The program has successfully deleted all default shares  
echo. 
echo   Press any key to exit
pause>nul

Recommended Today

Summary of import and export usage in JavaScript

import import 和 require 的区别 import 和js的发展历史息息相关,历史上 js没有模块(module)体系,无法将一个大程序拆分成互相依赖的小文件,再用简单的方法拼装起来。这对开发大型工程非常不方便。在 ES6 之前,社区制定了一些模块加载方案,最主要的有 CommonJS 和 AMD 两种。前者用于服务器,后者用于浏览器。ES6 在语言标准的层面上,实现了模块功能,而且实现得相当简单,完全可以取代 CommonJS 和 AMD 规范,成为浏览器和服务器通用的模块解决方案。也就是我们常见的 require 方法。 比如 `let { stat, exists, readFile } = require(‘fs’);` 。ES6 在语言标准的层面上,实现了模块功能。ES6 模块不是对象,而是通过export命令显式指定输出的代码,再通过import命令输入。 import 的几种用法: 1. import defaultName from ‘modules.js’; 2. import { export } from ‘modules’; 3. import { export as ex1 } from […]