在.bat中有一个脚本用于在win7上删除共享(没有pipe理员共享像ADMIN $等)
@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 ) )
可能是删除股份存在的另一种方式? PS域用户超过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
类公开的方法即可。