Deletes default shares for all partitions. bat
Copy Code code as follows:
@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: First enumerate the existing partitions, and then delete each partition by the name of the share;
:: To prevent admin$ sharing by modifying the registry to reload at the next boot;
:: ipc$ share requires administritor permission to be deleted successfully
::
:: JM changed in 2006-5-12
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Title Default shared deletion device
Echo.
Echo------------------------------------------------------
Echo.
Echo begins to delete 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 removed the default share named%%a$ | | The default share with the Echo name%%a$ does not exist
)
)
NET share admin$/delete>nul 2>nul && Echo successfully removed the default share named admin$ | | The default share with the Echo name admin$ does not exist
Echo.
Echo------------------------------------------------------
Echo.
net stop Server>nul 2>nul && echo Server service has stopped.
net start Server>nul 2>nul && echo Server service 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 reload 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, this feature requires Administritor permissions 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 the registry file to change the system default settings.
REGEDIT/S C:\delshare.reg
Del c:\delshare.reg && echo temporary files have been deleted.
Echo.
Echo------------------------------------------------------
Echo.
The ECHO program has successfully removed all default shares.
Echo.
Echo Press any key to exit ...
Pause>nul