Results 1 to 3 of 3
  1. #1
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Share permissions by script (XP SP2)

    I need to create a .BAT file that will create a share on my home PC and set permissions to allow access. I need to do this with a BAT file as the drive to be shared doesn't exist at boot time, so I can't just have a permanent share.

    It's easy to create the share with a NET SHARE command, but this creates it as a read-only share. I need to set the permissions to allow a particular user (or group) to have full control. Is there a simple way to do this from the command line?

    StuartR

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts

    Re: Share permissions by script (XP SP2)

    A quick test shows that if you do the usual NET SHARE sharename=C:sharepath and then look at the share permissions in Windows Explorer it shows Everyone with Allow Permissions: Full Control, Change and Read.

    So do you mean Directory/File Security Permissions, for which CACLS or similar might be appropriate?

    Alternatively, in various NT4 and the W2K Resource Kits (but not subsequently) there was a utility called RMTSHARE:<pre>RMTSHARE server
    serversharename
    serversharename=driveath [/USERS:number | /UNLIMITED]
    [/REMARK:"text"]
    [/GRANT [user[erm][ /GRANT user[erm]]]]
    [/REMOVE user]
    serversharename [/USERS:number | /UNLIMITED]
    [/REMARK:"text"]
    [/GRANT [user[erm][ /GRANT user[erm]]]]
    [/REMOVE user]
    serversharename /DELETE

    NOTE: if a sharename or path contains spaces, it should be enclosed
    in quotes:
    server"with space"="c:with space"

    perm can be Read, Change, or Full Control

    EXAMPLE: RMTSHARE Computer1Share1 /GRANT YourDomainYou:Read</pre>

    Of any relevance?

    If you want to do any actual copying of Stuff and permissions from 'somewhere else' you could investigate the resource kit utility PERMCOPY ("copies the permissions (ACLs) from one share to another"), also XCOPY /O, and ROBOCOPY (and probably XXCOPY also).
    BATcher

    Time prevents everything happening all at once...

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Share permissions by script (XP SP2)

    Oh how embarrassing!

    Because a share created from the Windows Explorer GUI has a default access permission of Everyone: Read, I had assumed the same would apply to Net Share, without bothering to check.

    Thank you.

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •