Wednesday, January 9, 2013

Create a Windows share programmatically

To create a share called mydir that points to c:\mydocs\mydir and gives everyone full permissions you would use the following command

net share mydir=C:\mydocs\mydir /GRANT:Everyone,FULL

NOTE: If you are using Windows XP, or Windows Server 2003, I recommend using Everyone with full permissions and then using the ACL (Windows permissions) to restrict access. Otherwise, you have two levels of permissions and they can be difficult to maintain if you try to make them match. Newer versions of the OS make this work better though.

No comments: