Submitted By: Anonymous Submission

Deletes the C$ administrative share from a computer.

Visual Basic
Edit|Remove
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'C$'")

For Each objShare in colShares
    objShare.Delete
Next

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'C$'")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'C$'")

For Each objShare in colShares
    objShare.Delete
Next