Delete Windows share by script

article #172, updated 4032 days ago

Put the below in a VBS file and run it (from a batch file perhaps) with ‘wscript filename.vbs’.

' The name of the share.
strShareName = "SHARE"

' SERVERNAME has to be the hostname of the machine containing the sahre
Set objfServer = GetObject("WinNT://SERVERNAME/lanmanserver")
objfServer.Delete "Fileshare", strShareName
Set objfServer= Nothing

Categories: