Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share Permissions 1

Status
Not open for further replies.

w33mhz

MIS
May 22, 2007
529
US
Does anyone know how to modify share permissions on a folder or set of folders? I know cacls and xcacls will do NTFS permissions, but will they do share permissions?
 
You can also more intuitively grant users access to shares with NET SHARE.

Code:
net share AccountingDept=D:\Departments\Accounting

Code:
net share AccountingDept=D:\Departments\Accounting /GRANT:domain\Accountants,FULL /GRANT:domain\Auditors,READ

I think the above is a lot easier to script.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
A sample of how you might script this. You just need to edit the parts in [red]red[/red]

Code:
[green]
'==========================================================================
'
' NAME: CreateShareWithPermissions.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]    
' COPYRIGHT (C) 2009 All rights reserved
' DATE  : 5/23/2009
'
' COMMENT: Creates a new share and assigns permissions.
'
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'==========================================================================

'Declare the arrays[/green]
Dim FullPermArray
Dim ReadPermArray
[green]
'Populate the data in the arrays[/green]
FullPermArray=Array([red]"domain\accounting","domain\acctmgr"[/red])
ReadPermArray=Array([red]"domain\auditors"[/red])
[green]
'Set our folder path and share name[/green]
strFolderPath = "[red]D:\DepartmentShares\Accounting"[/red]
strShareName = "[red]Accounting"[/red]
[green]
'Don't edit any further
'Create our Shell Object[/green]
Dim WshShell
Set WshShell = CreateObject("wscript.Shell")
On Error Resume Next
[green]
'Build our permissions string for full permissions[/green]
For Each User In FullPermArray[green]
        'Comment out the next line if there are no Full Perm users[/green]
	Perms = Perms & "/Grant:" & User & ",Full "
Next[green]
'Build our permissions string for read permissions[/green]
For Each User In ReadPermArray[green]
        'Comment out the next line if there are no READ Perm users[/green]
	Perms = Perms & "/Grant:" & User & ",Read "
Next[green]
On Error GoTo 0
'Execute the command[/green]
WshShell.Run ("CMD.EXE /C NET SHARE " & strShareName & "=" & strFolderPath & " " & Perms)

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top