bsharath
asked on
Add a user to all shares in the machine
Hi,
I need a way to add a user to the share and NTFS permissions on all shares in the machine with read permissions.Is there a way to do this.
Regards
Sharath
I need a way to add a user to the share and NTFS permissions on all shares in the machine with read permissions.Is there a way to do this.
Regards
Sharath
How many shared drive are there?
ASKER
More than 1000
ASKER
there are 6 drives and 100 folders.This is a NAS box with windows 2000 OS
I think what we can do is list all the shares in the server and put that in a text file and then use setacl to set the permission for all the folders
regards
Chandru
regards
Chandru
Have you used shareenumerator from sysinternals
ASKER
Yes...
Does this have any option?
Does this have any option?
What option are you referring to? using this we can just pull out the shares
ASKER
I have the list of shares taken from shareenum.Now what i the next step?
Did you manage to get the list from the particular server?
Try this script......
regards
Chandru
Try this script......
regards
Chandru
Option Explicit
Dim objFs, objShare
Dim strServer
' The section sets the variables
strServer = "servername"
' Connects to the operating system's file system
set objFs = GetObject("WinNT://" _
& strServer & "/LanmanServer,FileService")
' Loops through each share
For Each objShare In objFs
WScript.Echo objShare.path
Next
ASKER
I managed to get all the shares to a file.
Now need a way to add a user to all shares.
Now need a way to add a user to all shares.
try this script........
Make sure you have the setacl in c:\windows\system32
regards
Chandru
Make sure you have the setacl in c:\windows\system32
regards
Chandru
Option Explicit
Dim objFs, objShare
Dim strServer
Dim StrFolder
Dim objshell
' The section sets the variables
strServer = "servername"
' Connects to the operating system's file system
set objFs = GetObject("WinNT://" _
& strServer & "/LanmanServer,FileService")
' Loops through each share
For Each objShare In objFs
StrFolder = objShare.path
wscript.echo objshare.path
'SetACL to set permissions
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /c Setacl -on " & strFolder & " -ot file -actn ace -ace n:username;p:read;m:grant;"
wscript.sleep (10000)
Next
'Quit
Wscript.quit
ASKER
What will the script do..>Will it add a user to all folders.(Shared folders)
yes. I have added wscript.echo so that you can check after a folder whether the permission is applied
regards
Chandru
regards
Chandru
ASKER
I saved the code to a vbs file and ran it...Nothing changed.Is there any where i need to add the username.Or is there something i am missing
yes. change the username in the script to suit your needs and make sure setacl.exe is there from the location where the script is run or %systemroot%\system32
regards
Chandru
regards
Chandru
You need to change the servername aswell
regards
Chandru
regards
Chandru
ASKER
Should i change this part
n:username;p:read;m:grant
^Myname
n:username;p:read;m:grant
^Myname
only the username as bsharath
ASKER
Excellent Chandru...
Was wanting a script like this from 2yrs...
One more thing can you get the results to a file on what it has added and to what folders.
If the user is already there what happens.In the results we can see all...
Was wanting a script like this from 2yrs...
One more thing can you get the results to a file on what it has added and to what folders.
If the user is already there what happens.In the results we can see all...
Hope you didn't post the question in EE.
It doesn't make any difference if the user is already there.
I think if you can redirect the result using cscript
It doesn't make any difference if the user is already there.
I think if you can redirect the result using cscript
ASKER
I tried this
C:\>cscript addpermissions.vbs > c:\re.txt
Re,txt file has just this...
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
F:\Softwares\VPN
F:\c9934e862e22ff853c05cfg hf
Any way to get the details...
C:\>cscript addpermissions.vbs > c:\re.txt
Re,txt file has just this...
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
F:\Softwares\VPN
F:\c9934e862e22ff853c05cfg
Any way to get the details...
Hope you removed the wscript.echo
Can you be more specific about what details?
ASKER
If i remove wscript.echo
I get this.
C:\>cscript addpermissions.vbs > c:\re.txt
C:\addpermissions.vbs(19, 2) Microsoft VBScript runtime error: Object doesn't su
pport this property or method: 'path'
For details i mean. Which shares has it updated and which it sould not update.
Success/Failures.
As for a folder VPN there was sharath already as member as Full access so when i run the script nothing happened...So if i can get a results file that says
Added Sharath to share "VPN"
It would be easy when i use this script to give permissions for 1000 folders
I get this.
C:\>cscript addpermissions.vbs > c:\re.txt
C:\addpermissions.vbs(19, 2) Microsoft VBScript runtime error: Object doesn't su
pport this property or method: 'path'
For details i mean. Which shares has it updated and which it sould not update.
Success/Failures.
As for a folder VPN there was sharath already as member as Full access so when i run the script nothing happened...So if i can get a results file that says
Added Sharath to share "VPN"
It would be easy when i use this script to give permissions for 1000 folders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get the results file like this...
Processing ACL of: <\\?\F:\Softwares\VPN>
SetACL finished successfully.
Processing ACL of: <\\?\F:\c9934e862e22ff853c 05cfghf>
SetACL finished successfully.
Processing ACL of: <\\?\F:\Softwares\VPN>
SetACL finished successfully.
Processing ACL of: <\\?\F:\c9934e862e22ff853c
SetACL finished successfully.
That is the results file created by the setacl
Do you need anything else?
Do you need anything else?
ASKER
No that would be fine.Thanks a lot Chandru...
ASKER
Excellent Chandru Thanks....
Glad i helped you in a script which you were searching for a long time
Hope this solved your purpose
regards
Chandru
Hope this solved your purpose
regards
Chandru
ASKER
Yes Chandru thanks a lot...
You saved hrs of my manual work with this script.Which can do the job in Minutes.
You saved hrs of my manual work with this script.Which can do the job in Minutes.
No worries!