删除不包括C $ D $ ADMIN $…等的股票 [英] Delete shares excluding C$ D$ ADMIN$… etc
本文介绍了删除不包括C $ D $ ADMIN $…等的股票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
.bat中有一个脚本,用于在win7上共享(无需管理员共享,例如ADMIN $等)
Have a script in .bat for deliting shares on win7 (without admins shares like ADMIN$ etc.)
@echo off
(wmic path Win32_OperatingSystem get /value|find "ProductType=1" > nul) || (echo [e] Server OS & goto :eof)
setlocal EnableDelayedExpansion
for /f "delims=" %%a in ('wmic share get name /value ^| findstr /r /v "^$"') do (
for /f "tokens=2 delims==" %%b in ("%%a") do (
set VarAdminAllowed=NotAllowed
for %%c in (ADMIN$ IPC$ print$ fax$ A$ B$ 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 %%b == %%c set VarAdminAllowed=Allowed
)
if !VarAdminAllowed! == NotAllowed net share /delete "%%b" /yes
)
)
可能是删除存在的共享的另一种方法? 超过3000+的P. S.域用户
May be another way to delete shares exist ? P. S. Domain users over 3000+
推荐答案
@echo off
setlocal enableextensions disabledelayedexpansion
rem Win32_OperatingSystem class
rem https://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx
( wmic OS where "ProductType=1" | find "Boot" ) >nul 2>nul || (
echo [e] Server OS
goto :eof
)
rem Win32_Share class
rem https://msdn.microsoft.com/en-us/library/aa394435%28v=vs.85%29.aspx
wmic share where "Type < 2147483648" call Delete
只需使用wmi
类公开的方法.
Just use the methods exposed by the wmi
class.
这篇关于删除不包括C $ D $ ADMIN $…等的股票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文