How to implement batch processing for deleting default shares
This article will explain in detail how to delete the default sharing of batch processing, the editor found it very practical, so share to you as a reference, I hope you can learn something after reading this article.
The code is as follows:
@ echo off
:::
::
:: enumerate the existing partitions, and then delete the shares named by the partition name one by one
:: prevent admin$ shares from reloading the next boot by modifying the registry
:: IPC$ share requires administritor permission to delete successfully
::
:::
Title default share deletion
Color 1f
Echo.
Echo
Echo.
Echo begins to delete the default share under each partition.
Echo.
For an 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 default share named% a $| echo name% a $does not exist
)
)
Net share admin$ / delete > nul 2 > nul & & echo successfully deleted the default share named admin$ | | echo default share named admin$ does not exist
Echo.
Echo
Echo.
Net stop Server / y > nul 2 > nul & & echo Server service has stopped.
The net start Server > nul 2 > nul & & echo Server service has started.
Echo.
Echo
Echo.
Echo modifies the registry to change the system default settings.
Echo.
Echo is creating a registry file.
Echo Windows Registry Editor Version 5.00 > c:\ delshare.reg
:: disable Admin$ sharing through the registry to prevent loading again after reboot
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 IPC$ share. Administritor permission is required for this feature to be deleted successfully.
Echo [HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Lsa] > c:\ delshare.reg
Echo "restrictanonymous" = dword:00000001 > > c:\ delshare.reg
Echo is importing a registry file to change the system default settings.
Regedit / s c:\ delshare.reg
Del c:\ delshare.reg & & echo temporary file has been deleted.
Echo.
Echo
Echo.
The echo program has successfully deleted all default shares.
Echo.
Echo press any key to exit.
Pause > nul
This is the end of this article on "how to delete the default shared batch". 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, please share it for more people to see.