In the left pane, browse to the folder you want to start or stop sharing.
Right-click on the folder and select Sharing and Security (or Sharing on Windows 2000).
To stop sharing the folder, select Do not share this folder.
To share the folder, select Share this folder. Enter the Share name, enter a description for the share in the Comment field, and specify the User limit.
Click OK to close the dialog box.
The following command creates a share called
> net share "Perl Libs"=d:\perl\lib /unlimited /remark:"Core Perl modules"
/unlimited option means
that an unlimited number of users can access the share
simultaneously. You can limit the number of simultaneous users by
using the /users:
<Number> option instead.
This command deletes a share:
> net share "Perl Libs" /delete
' This code creates a share. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strPath = "d:\perl\lib" strName = "Perl Libs" intType = 0 ' share a disk drive resource intMaxAllowed = 10 strDescr = "Core Perl modules" ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set objShare = objWMI.Get("Win32_Share") intRC = objShare.Create(strPath, strName, intType, intMaxAllowed, strDescr) if intRC <> 0 then WScript.Echo "Error creating share: " & intRC else WScript.Echo "Successfully created share" end if ' This code deletes a share. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strName = "Perl Libs" ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set objShare = objWMI.Get("Win32_Share.Name='" & strName & "'") intRC = objShare.Delete if intRC <> 0 then WScript.Echo "Error deleted share: " & intRC else WScript.Echo "Successfully deleted share" end if
After you create a share, you need to modify the access control list (ACL) to include the users and groups that can access the contents of the share (see Recipe 4.25 for more on this).
If you want to create a hidden share, simply append "$" to the end of the share name. The only difference in a hidden share is that it won't be directly viewable when listing the shared folders on a server. Hiding shares is kind of like hiding files (Recipe 4.12); it is up to the application to display them or not. So hidden shares are not truly hidden, but they will not be visible to the casual user.