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 ...
-
1st May 2008, 12:55 PM #1 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
-
-
IDG Tech News
-
1st May 2008, 01:08 PM #2 I still like RMTSHARE.exe for things like this ... simple and easy, but does not sort out the caching issue.
-
-
1st May 2008, 02:32 PM #3 rmtshare and xcacls here too.
if you have foldernames the same as usernames that makes things a lot easier.
-
-
1st May 2008, 03:01 PM #4 Cheers got a hold of this wee tool now, try it out later.
-
-
2nd May 2008, 12:11 PM #5 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.
-
-
2nd May 2008, 04:13 PM #6 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: 
Similar Threads
-
Replies: 8
Last Post: 15th February 2008, 01:45 PM
-
By apeo in forum Virtual Learning Platforms
Replies: 4
Last Post: 13th June 2007, 11:20 AM
-
Replies: 2
Last Post: 27th April 2007, 06:41 AM
-
By ICTNUT in forum How do you do....it?
Replies: 10
Last Post: 28th June 2006, 11:42 AM
-
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
-
Forum Rules