Delete the default shared batch _dos/bat

Source: Internet
Author: User
Tags echo name
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
Color 1f
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/y>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

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.