Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement batch processing for deleting default shares

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 258

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report