Help and Support

Article ID: 234234 - Last Review: August 8, 2007 - Revision: 3.3

How to Manage File Shares Using ADSI

This article was previously published under Q234234
Expand all | Collapse all

SUMMARY

This article describes how to use Active Directory Services Interface (ADSI) to manage file shares on local and remote computers.

MORE INFORMATION

You can use ADSI to write scripts or programs to manage shares on both local and remote computers. The different properties you can use in the IADsFileShare object are listed in the following table.

Collapse this tableExpand this table
PropertyDescription
CurrentUserCountThe number of users currently connected to the share. (Read Only)
DescriptionThe friendly description for the file share.
HostComputerThe ADsPath for the computer in which this share resides.
MaxUserCountThe maximum number of users that are allowed to connect to this share simultaneously.
PathThe local file system path for the shared folder.

The following scripts, written in VBScript, take advantage of the IADsFileShare object.

The Create_Share.vbs script creates a new share on 'MYCOMPUTER,' and then sets some of the common file share attributes.
Set ShareSrvObj = GetObject("WinNT://MYCOMPUTER/LANMANSERVER")
Set NewShareObj = ShareSrvObj.Create("fileshare", "DWNLDShare")
NewShareObj.Path = "C:\Download"
NewShareObj.MaxUserCount = 10
NewShareObj.Description = "This is a share for my downloaded files."
NewShareObj.SetInfo

The List_Shares.vbs script lists all of the shares on 'MYCOMPUTER' and the local path for the share.
Set ShareSrvObj = GetObject("WinNT://MYCOMPUTER/LANMANSERVER")
For Each ShareObj in ShareSrvObj
    WScript.Echo ShareObj.Name & " = " ShareObj.Path
Next


For information about ADSI, please visit the following Microsoft Web site:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/activedirectory/default.mspx (http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/activedirectory/default.mspx)
For information about Windows Script Host, please visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/library/ms950396.aspx (http://msdn2.microsoft.com/en-us/library/ms950396.aspx)

APPLIES TO
  • Microsoft Windows NT Server 4.0, Terminal Server Edition
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Professional Edition
  • Microsoft Windows NT Server 4.0 Standard Edition
  • Microsoft Windows 98 Standard Edition
Keywords: 
kbenv kbhowto kbnetwork KB234234

Article Translations

 

Related Support Centers