Jump to content

Recommended Posts

Posted

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 - [email protected]

'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=impersonate,(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.SpawnInstance_()

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=impersonate}!root/cimv2:Win32_Trustee").Spawninstance_

set account = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Account.Name='" & strName & "',Domain='" & strDomain &"'")

set accountSID = getObject("Winmgmts:{impersonationlevel=impersonate}!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=impersonate}!root/cimv2:Win32_Trustee").Spawninstance_

set account = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Group.Name='" & strName & "',Domain='" & strDomain &"'")

set accountSID = getObject("Winmgmts:{impersonationlevel=impersonate}!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

Posted

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.

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...