Announcement

Collapse
No announcement yet.

Script to look for shares on a PC and disable them

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to look for shares on a PC and disable them

    Hi all. I have many users who are sharing folders, and i would like to put a stop to it. Is there a script or other way of mass deployment to remove the various shares that users have created? I do not want the administrative windows shares to be deleted though, only those created by users. I am looking to do it as a startup script is at all possible. Thanks!

  • #2
    Re: Script to look for shares on a PC and disable them

    i have the same issue here. Its impossible moving around on 500PCs to check the shared folders and removing them

    Comment


    • #3
      Re: Script to look for shares on a PC and disable them

      Have a look at this script from REMS: http://forums.petri.com/showthread.php?p=113477
      Caesar's cipher - 3

      ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

      SFX JNRS FC U6 MNGR

      Comment


      • #4
        Re: Script to look for shares on a PC and disable them

        Originally posted by L4ndy View Post
        Have a look at this script from REMS: http://forums.petri.com/showthread.php?p=113477
        Thanks, L4ndy. I did find that script when searching, but it did not seem to work at all when I tested it on vista. It gave "System error 123".

        Comment


        • #5
          Re: Script to look for shares on a PC and disable them

          Originally posted by dougstech View Post
          Thanks, L4ndy. I did find that script when searching, but it did not seem to work at all when I tested it on vista. It gave "System error 123".
          "The filename, directory name, or volume label syntax is incorrect."

          Is the share created on a removable/USB device?


          You can give this vbscript a try (tested on Windows XP)
          Code:
          strComputer = "."
          
          Set objWMIService = GetObject("winmgmts:" _
             & "{impersonationLevel=impersonate}!\\" _
             & strComputer & "\root\cimv2")
          
          ' Share types
          '   0 = Disk_Drive
          '   1 = Print_Queue
          '   2 = Device
          '   3 = IPC
          ' Built-in volume and Administrative shares have
          ' type values above 2147483600
          '   2147483648 = Disk Drive Admin
          '   2147483649 = Print Queue Admin
          '   2147483650 = Device Admin
          '   2147483651 = IPC Admin
          
          On Error Resume Next
          Set colShares = objWMIService.ExecQuery( _
             "Select * from Win32_Share Where type < 10")
          
          For each objShare in colShares
             objShare.Delete
          Next
          On Error Goto 0
          \Rems
          Last edited by Rems; 12th December 2009, 13:45.

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: Script to look for shares on a PC and disable them

            Thanks, Rems. That script worked beautifully. I was testing the other script running from my desktop folder.

            Comment

            Working...
            X