+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Create a hidden share for home directories in Coding and Web Development; Anyone know of a script that will allow me to set home user drives as a hidden share and set ...
  1. #1
    originofsymmetry's Avatar
    Join Date
    Jun 2007
    Posts
    187
    Thank Post
    9
    Thanked 15 Times in 12 Posts
    Rep Power
    17

    Create a hidden share for home directories

    Anyone know of a script that will allow me to set home user drives as a hidden share and set the share permissions? Disabling caching would be a bonus too. I found this at Win32 Scripting.... Everything you need to get up and running

    '====================
    'ShareSetup.vbs
    'Author: Jonathan Warnken - jon.warnken@gmail.com
    'Credits: parts of various other posted scripts used
    'Requirements: Admin Rights
    '====================
    Option Explicit
    Const FILE_SHARE = 0
    Const MAXIMUM_CONNECTIONS = 25
    Dim strComputer
    Dim objWMIService
    Dim objNewShare

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objNewShare = objWMIService.Get("Win32_Share")
    Call sharesec ("C:\Robot", "Robot", "SCOT SHARE", "POSTerminalUsers_GG")

    Sub sharesec(Fname,shr,info,account)
    Dim FSO
    Dim Services
    Dim SecDescClass
    Dim SecDesc
    Dim Trustee
    Dim ACE
    Dim Share
    Dim InParam
    Dim Network
    Dim FolderName
    Dim AdminServer
    Dim ShareName

    FolderName = Fname
    AdminServer = "\\" & strComputer
    ShareName = shr

    Set Services = GetObject("WINMGMTS:{impersonationLevel=impersonat e,(Security)}!" & AdminServer & "\ROOT\CIMV2")
    Set SecDescClass = Services.Get("Win32_SecurityDescriptor")
    Set SecDesc = SecDescClass.SpawnInstance_()

    'Set Trustee = Services.Get("Win32_Trustee").SpawnInstance_
    'Trustee.Domain = Null
    'Trustee.Name = "EVERYONE"
    'Trustee.Properties_.Item("SID") = Array(1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0)

    Set Trustee = SetGroupTrustee("Retail", account) 'Use SetGroupTrustee for groups and SetAccountTrustee for users
    Set ACE = Services.Get("Win32_Ace").SpawnInstance_
    ACE.Properties_.Item("AccessMask") = 2032127 '2032127 = "Full"; 1245631 = "Change"; 1179817 = "Read"
    ACE.Properties_.Item("AceFlags") = 3
    ACE.Properties_.Item("AceType") = 0
    ACE.Properties_.Item("Trustee") = Trustee
    SecDesc.Properties_.Item("DACL") = Array(ACE)
    Set Share = Services.Get("Win32_Share")
    Set InParam = Share.Methods_("Create").InParameters.SpawnInstanc e_()
    InParam.Properties_.Item("Access") = SecDesc
    InParam.Properties_.Item("Description") = "Public Share"
    InParam.Properties_.Item("Name") = ShareName
    InParam.Properties_.Item("Path") = FolderName
    InParam.Properties_.Item("Type") = 0
    Share.ExecMethod_ "Create", InParam
    End Sub


    Function SetAccountTrustee(strDomain, strName)
    Dim objTrustee
    Dim account
    Dim accountSID
    set objTrustee = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_Trustee").Spawninstance_
    set account = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_Account.Name='" & strName & "',Domain='" & strDomain &"'")
    set accountSID = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_SID.SID='" & account.SID &"'")
    objTrustee.Domain = strDomain
    objTrustee.Name = strName
    objTrustee.Properties_.item("SID") = accountSID.BinaryRepresentation
    set accountSID = nothing
    set account = nothing
    set SetAccountTrustee = objTrustee
    End Function


    Function SetGroupTrustee(strDomain, strName)
    Dim objTrustee
    Dim account
    Dim accountSID
    set objTrustee = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_Trustee").Spawninstance_
    set account = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_Group.Name='" & strName & "',Domain='" & strDomain &"'")
    set accountSID = getObject("Winmgmts:{impersonationlevel=impersonat e}!root/cimv2:Win32_SID.SID='" & account.SID &"'")
    objTrustee.Domain = strDomain
    objTrustee.Name = strName
    objTrustee.Properties_.item("SID") = accountSID.BinaryRepresentation
    set accountSID = nothing
    set account = nothing
    set SetGroupTrustee = objTrustee
    End Function

    Any help on how to personalise it for my network would be a bonus, not musch of a scripter myself. Thnx in advance

  2. #2

    GrumbleDook's Avatar
    Join Date
    Jul 2005
    Location
    Gosport, Hampshire
    Posts
    9,992
    Thank Post
    1,359
    Thanked 1,828 Times in 1,135 Posts
    Blog Entries
    19
    Rep Power
    602
    I still like RMTSHARE.exe for things like this ... simple and easy, but does not sort out the caching issue.

  3. #3
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,529
    Thank Post
    108
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    40
    rmtshare and xcacls here too.
    if you have foldernames the same as usernames that makes things a lot easier.

  4. #4
    originofsymmetry's Avatar
    Join Date
    Jun 2007
    Posts
    187
    Thank Post
    9
    Thanked 15 Times in 12 Posts
    Rep Power
    17
    Cheers got a hold of this wee tool now, try it out later.

  5. #5
    originofsymmetry's Avatar
    Join Date
    Jun 2007
    Posts
    187
    Thank Post
    9
    Thanked 15 Times in 12 Posts
    Rep Power
    17
    Could someone post a example script for this? I'm having a little bit of trouble getting it to go. Just restating, I want to batch share (hidden) users home directories which all exist in the same parent folder and set the following permissions:

    Jonny - Full Control
    Domain Admins - Full Control
    username- Full Control
    Staff - Read

    The foldername is always the same as the users logon name and creating a share with the folder name would be grand. Thnx in advance for any assistance.

  6. #6
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    985
    Thank Post
    58
    Thanked 165 Times in 117 Posts
    Rep Power
    68
    Hi originofsymmetry,

    Yes i know of a script it will be available shortly as open source it is based on the script to found. The script i have developed links SIMS.net,AD and Moodle. It also handles profiles, terminal services profiles and settings to name a few things.

SHARE:
+ Post New Thread

Similar Threads

  1. Home Directories on a DC - Good or Bad
    By Kyle in forum Windows
    Replies: 8
    Last Post: 15th February 2008, 01:45 PM
  2. Home Directories on Moodle
    By apeo in forum Virtual Learning Platforms
    Replies: 4
    Last Post: 13th June 2007, 11:20 AM
  3. Replies: 2
    Last Post: 27th April 2007, 06:41 AM
  4. Use Ghost to create a hidden restore partition?
    By ICTNUT in forum How do you do....it?
    Replies: 10
    Last Post: 28th June 2006, 11:42 AM
  5. Shadow Volume Copy and Hidden Share
    By MartinDixon in forum Windows
    Replies: 5
    Last Post: 29th March 2006, 07:30 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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