Windows – Changing the Permissions on a Windows Share Remotely

command-line-interfacenetwork-sharewindows

I read about the Net Share command a lot of places. It appears to have the ability to stop a remote share from being shared using the /DELETE argument, and it also appears to be able to add users to the share using /GRANT.

Now one thing that seems not possible is to do is to remove people from the remote share using the Net Share command. Is there some way of doing this?

Best Answer

Since you seem to be using this in a script:

  1. you could use the 3rd party open source SetACL utility to modify remote share permissions

  2. the same goes for Microsoft's RMTSHARE which is a separate resource kit download

  3. you could use Enter-PSSession or InvokeCommand -Computer in PowerShell and remote the share permission management through PowerShell commands too. If you don't like / use / want PowerShell, WMI (which is used for share permission management in the PowerShell examples you find on the net) is remoteable all by itself and scriptable through other languages (e.g. VBScript) too.

WMI is rather complex to script and debug though, so it can become a pain in the bum, but is the only approach which would work out of the box, without installing additional software.